放在动作条一个进度 [英] Put a progressBar on ActionBar

查看:162
本文介绍了放在动作条一个进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一个不确定的进度条上的动作条。我用的而ActionView放像Google+应用,例如进度。

 <项目
    机器人:ID =@ + ID / menu_progress
    机器人:actionLayout =@布局/ action_progress
    机器人:menuCategory =容器
    机器人:showAsAction =总是>
< /项目>
 

问题是,进度条被认为是一个项目,因此在Nexus S的人像模式我只有一个在动作条其他项目,而在Google+上,我可以看到两个项目加上进度。 这怎么可能使用Android的动作条放一个进度?

解决方案

注意:<一href="http://developer.android.com/reference/android/support/v7/app/AppCompatActivity.html#setSupportProgressBarIndeterminate(boolean)"相对=nofollow>下面的功能现在pcated在支持库德$ P $。

您需要调用

  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)
 

的onCreate() 设置活动的布局之前:

例如。

  @覆盖
保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ... //设置布局等
 

  

如果您使用的是支持库替换< STRONG> requestWindowFeature 是 supportRequestWindowFeature

然后调用

  setProgressBarIndeterminateVisibility(真正的);
 

您的活动,只要你想显示进度微调。

I am trying to put an indeterminate ProgressBar on the actionBar. I was using an actionView to put the progressBar like Google+ app for example.

<item
    android:id="@+id/menu_progress"
    android:actionLayout="@layout/action_progress"
    android:menuCategory="container"
    android:showAsAction="always">
</item>

the problem is that the progress bar is considered as an item and therefore on a Nexus S portrait mode I have only one other item on the actionbar while on Google+ I can see two items plus the progressBar. How is it possible to put a progressbar using the android actionbar?

解决方案

NOTE: The functionality below is now deprecated in the Support Library.

You need to call

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS)

in your onCreate() before setting the activity's layout:

e.g.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ... // set layout etc

If you are using the support library replace requestWindowFeature with supportRequestWindowFeature

And then call

setProgressBarIndeterminateVisibility(true);

on your Activity whenever you want to show the progress spinner.

这篇关于放在动作条一个进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆