In my AppWidgetProvider, I do following:
@Override
public void onReceive(Context ctx, Intent intent) {
final String action = intent.getAction();
if (action.equals(NEXTPAGE_ACTION)) {
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ctx);
RemoteViews rv = new RemoteViews(ctx.getPackageName(), R.layout.widget_layout);
rv.setViewVisibility(R.id.page1, View.GONE);
rv.setViewVisibility(R.id.page2, View.VISIBLE);
final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
}
Although I'm updating the layout via updateAppWidget, the change is not really reflected on the UI. What could be possibly going wrong? Thanks much!
“RemoteView controls PC from a mobile device such as a smartphone, as well as control Android device from a PC or mobile. “
Have you tried using INVISIBLE and not GONE? Gone will remove the view as if it were never there. And invisible will hold the view's place in the layout, but make it invisible.
rv.setViewVisibility(R.id.page1, View. INVISIBLE);
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