I have a partial workaround for the joinAero case. If the goal is simply to show or hide an undefined progress bar in widgets, the trick is to set and clear the widget layout resource in the code.
1) Define the widget layout containing the ProgressBar. No need to assign an identifier. preference_widget_progressbar.xml:
<?xml version="1.0" encoding="utf-8"?> <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" />
2) Do not specify the widget in settings.xml
<package.ProgressBarPreference android:key="key" android:summary="summary" android:title="title" />
3) When you want to show the progress bar, set the widget resource to preference_widget_progressbar. To clear it, set the value to 0. To update the screen, a call to notifyChanged() is required.
public void showProgressBar(boolean isVisible) {
Getting a pointer to the actual ProgressBar is surprisingly difficult, especially if the library project is preferred. I had some success using getIdentifier() according to this post , but this approach actually hides the entire widget, while setting the visibility to the ProgressBar leaves a visible empty widget.
ehartwell
source share