Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show progress indicator or progress Bar in the titleBar in android?

Tags:

android

I have an http request and some UI change during that time and I want to show the activity indicator during that time . I want to show it in the title bar. I want to show progress indicator in the title in android like activity indicator in iphone?

like image 299
Kikki Avatar asked Jan 23 '26 22:01

Kikki


2 Answers

From your activity code:

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
...
// when you need to show progress:
setProgressBarIndeterminate([true|false]);
like image 189
Pedantic Avatar answered Jan 26 '26 14:01

Pedantic


Yes, above two/three lines need to be used in following way.

1) Need to add this before calling setContentView() method.

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

2) Need to add this after calling setContentView() method.

setProgressBarIndeterminateVisibility(true);

To stop the progress indicator

setProgressBarIndeterminateVisibility(false);

If we start showing progress from a parent activity and closing from a child activity,

ParentActivity parent = (ParentActivity)getParent();
parent.setProgressBarIndeterminateVisibility(false);
like image 27
Rukmal Dias Avatar answered Jan 26 '26 14:01

Rukmal Dias