Android examples for User Interface:ProgressDialog
Change specified Progress Bar Visibility or Indeterminate Progress Bar
import android.app.Activity; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.text.Spannable; import android.text.SpannableString; import android.text.TextUtils; import android.view.View; import android.widget.ProgressBar; public class Main{ public static void changeProgressBarVisibility(Activity activity, boolean show) { ProgressBar progressBar = (ProgressBar) activity .findViewById(android.R.id.progress); changeProgressBarVisibility(progressBar, activity, show); }//from w w w . j ava2 s . c om public static void changeProgressBarVisibility(Fragment fragment, boolean show) { ProgressBar progressBar = (ProgressBar) fragment.getView() .findViewById(android.R.id.progress); changeProgressBarVisibility(progressBar, fragment.getActivity(), show); } public static void changeProgressBarVisibility(ProgressBar progressBar, Activity activity, boolean show) { if (progressBar != null) { if (show) progressBar.setVisibility(View.VISIBLE); else progressBar.setVisibility(View.GONE); } else { if (activity != null) { if (activity instanceof ActionBarActivity) { ActionBarActivity actionBarActivity = (ActionBarActivity) activity; actionBarActivity .setSupportProgressBarIndeterminateVisibility(show); } else { activity.setProgressBarIndeterminateVisibility(show); } } } } }