【发布时间】:2016-07-21 23:42:30
【问题描述】:
我在 Android 小部件中有一个按钮,声明如下:
<Button android:id="@+id/newWorkBtnWidget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ts_on_repair"/>
每次我尝试通过 RemoteViews 启用或禁用此按钮时,我都会收到错误 android.widget.RemoteViews$ActionException: view: android.widget.Button can't use method with RemoteViews: setEnabled(boolean)
我的代码:
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.widget);
remoteViews.setInt(R.id.newWorkBtnWidget, "setBackgroundResource",
R.drawable.green_button);
remoteViews.setBoolean(R.id.newWorkBtnWidget,
"setEnabled", false);
如何解决?
【问题讨论】:
-
呃,这是什么,
newWorkBtnWidget或newWorkButtWidget? -
抱歉,这应该是同一个按钮,已修复。无论如何,这与问题无关。
标签: android