开发者

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

开发者 https://www.devze.com 2023-03-11 06:05 出处:网络
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 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?


From your activity code:

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
...
// when you need to show progress:
setProgressBarIndeterminate([true|false]);


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消