Crash setTextViewTextSize en un widget solo sin Jelly Bean
Frecuentes
Visto 2,811 veces
8
I am making a widget in which you can specify the text size
controles.setTextViewTextSize(R.id.LblMsg, TypedValue.COMPLEX_UNIT_SP, textSize);
I am working with android 4.1
android:minSdkVersion="8" android:targetSdkVersion="16"
The problem is that it works correctly in android 4.1, but in any other version (ICS, gingerbread, etc) shows a forced close.
java.lang.NoSuchMethodError: android.widget.RemoteViews.setTextViewTextSize
If I remove the line of code where it is used "setTextViewTextSize", the application works perfectly.
I find no information about the reason for this error.
Agradezco cualquier ayuda.
saludos
3 Respuestas
7
if you wish to use something that works on all versions, use this:
remoteViews.setFloat(R.id.textView,"setTextSize",fontSize);
contestado el 19 de mayo de 13 a las 00:05
4
This method is only available since API level 16 (android 4.1) : http://developer.android.com/reference/android/widget/RemoteViews.html#setTextViewTextSize(int, int, float)
Respondido 28 ago 12, 12:08
1
hice esto
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
remoteViews.setTextViewTextSize(R.id.price, TypedValue.COMPLEX_UNIT_PX, 100f);
}
Respondido el 27 de enero de 16 a las 22:01
this solutions works but don't forget that last param is float
- so we must use f
at the end, it will be like: remoteViews.setTextViewTextSize(R.id.price, TypedValue.COMPLEX_UNIT_PX, 100f);
- Choletski
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android widget remoteview or haz tu propia pregunta.
and what is the method that I can use in earlier versions of android? thanks - Sergio76
Chech this out: stackoverflow.com/questions/6721616/… - sdabet