Android: Changing LinearLayout in a widget.

Posted by Profete162 on Stack Overflow See other posts from Stack Overflow or by Profete162
Published on 2010-04-28T01:30:28Z Indexed on 2010/04/28 1:33 UTC
Read the original article Hit count: 596

Filed under:
|

Hello all, I have this really annoying problem:

In my widget, i would like to change the background by code. I noticed on the Google doc than I can easily change the background of an Imageview:

remoteViews.setImageViewResource(R.id.my_iv, R.drawable.my_bg);

Ok, too easy, i want to change now the Linear layout.. What I read about the remoteview id that I can change a Bitmap, Int, Bool, String, etc... but not a drawable. So i guess i cannot use:

remoteViews.setBitmap(R.id.my_ll,"setBackgroundDrawable",BitmapFactory.decodeResource(context.getResources(), R.drawablemy_bg));

I am totally disapointed and tried a last idea:

views.setInt(R.id.my_ll,"setBackgroundResource",R.drawable.my_bg);

But The logcat told me:

android.widget.RemoteViews$ActionException:view: android.widget.LinearLayout can't use method with RemoteViews: setBackgroundResource(int)

I am totally lost and I really don't know what to do...

I would really appreciate any help.

Thank a lot!

© Stack Overflow or respective owner

Related posts about android

Related posts about java