Code example for RemoteViews

Methods: setImageViewResource, setOnClickPendingIntent, setViewVisibility

0
            // SettingsAppWidgetProvider.logD(">> updateView IN. Widget: "+appWidgetId+" Button:"+buttonID); 
 
            // SettingsAppWidgetProvider.logD("updateView -> Is Visible"); 
 
            // Set it visible 
            views.setViewVisibility(buttonLayout, View.VISIBLE);
            if (buttonSep != null) {
                views.setViewVisibility(buttonSep, View.VISIBLE);
            } 
 
            // SettingsAppWidgetProvider.logD("updateView -> Will register Intent"); 
            // Register the Intent 
            views.setOnClickPendingIntent(buttonLayout,
                    getLaunchPendingIntent(context, appWidgetId, buttonID));
 
            // SettingsAppWidgetProvider.logD("updateView -> Set current Icon"); 
            // Update icon to the one set by updateState 
            views.setImageViewResource(buttonIcon, currentIcon);
 
            // SettingsAppWidgetProvider.logD("updateView -> Set current State"); 
            views.setImageViewResource(buttonState, getButtonState(widgetPreferences));
        } 
    } 
 
    /** 
     * Creates PendingIntent to notify the widget of a button click.