嗨首先我很抱歉我的英语不好。如何设置 RemoteViews .setViewVisibility?当我单击它时,我想隐藏小部件按钮。这是我的代码。感谢帮助。
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++){
int appId = appWidgetIds[i];
widget = new RemoteViews(context.getPackageName(), R.layout.widget_wyglad);
Intent Tv = new Intent(context, client_widget.class);
Tv.setAction(AKCJA);
Tv.putExtra("test", AKCJA);
PendingIntent ptv = PendingIntent.getBroadcast(context, 0, Tv, 0);
widget.setOnClickPendingIntent(R.id.bt_wid_tv, ptv);
appWidgetManager.updateAppWidget(appId, widget);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null){
widget.setViewVisibility(R.id.bt_wid_tv, View.GONE);
}
else {Log.d("ERR", "EXTRAS ELSE");}
super.onReceive(context, intent);
}
}