【发布时间】:2010-04-28 01:30:28
【问题描述】:
我有一个非常烦人的问题:
在我的小部件中,我想通过代码更改背景。我在 Google 文档上注意到,我可以轻松更改 Imageview 的背景:
remoteViews.setImageViewResource(R.id.my_iv, R.drawable.my_bg);
好的,太容易了,我现在想更改线性布局。我读到的有关远程视图 ID 的内容,我可以更改位图、Int、Bool、字符串等……但不能更改可绘制对象。所以我想我不能使用:
remoteViews.setBitmap(R.id.my_ll,"setBackgroundDrawable",BitmapFactory.decodeResource(context.getResources(), R.drawablemy_bg));
我完全失望并尝试了最后一个想法:
views.setInt(R.id.my_ll,"setBackgroundResource",R.drawable.my_bg);
但是日志猫告诉我:
android.widget.RemoteViews$ActionException:view: android.widget.LinearLayout 不能使用 使用 RemoteViews 的方法: setBackgroundResource(int)
我完全迷失了,我真的不知道该怎么办......
非常感谢任何帮助。
非常感谢!
【问题讨论】: