I have an appwidget layout with a textview and an imageview.
Lint always tells me to replace it with a compound textview.
The problem is, how do I call setCompoundDrawables with a RemoteViews? is it possible?
thanks.
UPDATE: http://code.google.com/p/android/issues/detail?id=29249
This option was added in API Level 16 (Android 4.1 Jellybean):
http://developer.android.com/reference/android/widget/RemoteViews.html#setTextViewCompoundDrawables(int, int, int, int, int)
When you use setCompoundDrawables , you need code like :
Drawable img;
Resources res = getResources();
img = res.getDrawable(R.drawable.btn_img);
//You need to setBounds before setCompoundDrawables , or it couldn't display
img.setBounds(0, 0, img.getMinimumWidth(), img.getMinimumHeight());
btn.setCompoundDrawables(img_off, null, null, null);
So you must have ways to call getResources()! You can pass Activity context as a param to use getResources() & findViewById.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With