Listing 109 Modifying View properties within an App Widget Remote View

// Update a Text View views.setTextViewText(R.id.widget_text_view, "Updated Text"); views.setTextColor(R.id.widget_text_view, Color.BLUE); // Update an Image View views.setImageViewBitmap(R.id.widget_image_view, myBitmap); // Update a Progress Bar views.setProgressBar(R.id.widget_progressbar, 100, 50, false); // Update a Chronometer views.setChronometer(.id.widget_chronometer, SystemClock.elapsedRealtime(), null, true);

You can also set the visibility of any View hosted within Remote Views by calling setViewVisibility, as shown here:

views.setViewVisibility(R.id.widget_text_view, View.VISIBLE);

As described in the previous section, once you've made changes to a Remote Views object you must use the App Widget Manager to apply those changes to a particular widget, as shown here:

appWidgetManager.updateAppWidget(appWidgetId, views);

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment