Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no way to setProgressDrawable on RemoteViews

I'm trying to call setProgressDrawable on a ProgressBar in my RemoteViews
However there doesn't appear to be a setDrawable(<view_id>,<method>,<value>) method on RemoveViews I've tried setBitmap but setProgressDrawable takes a Drawable not a Bitmap and setInt doesn't work either.

I wanted to avoid having loads of different widget layout xml files just to handle different color progress bars.

like image 302
Rob Avatar asked Oct 23 '11 12:10

Rob


People also ask

What is android widget RemoteViews?

android.widget.RemoteViews. A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.

What is progress bar in Android?

Android ProgressBar is a graphical view indicator that shows some progress. Android progress bar displays a bar representing the completing of the task. Progress bar in android is useful since it gives the user an idea of time to finish its task.


1 Answers

There is no way to do this. My solution was not to create separate layout files, but one that contains all the different ProgressBars with different progressDrawables. In the code you then have to make only one of them visible.

Please note that for older android versions it is not allowed to call setViewVisibility on the Progressbar directly. The trick is to wrap a simple LinearLayout around each bar and to make this wrapper invisible/visible instead. Works fine for me.

like image 136
mdiener Avatar answered Sep 20 '22 04:09

mdiener