ProgressBar in an ActionBar, like GMail app with Refresh

后端 未结 4 1824
情书的邮戳
情书的邮戳 2021-01-30 14:18

I would like to do the same thing than the GMail application on Honeycomb tablets. When you click on the Refresh button, the icon is replaced by a ProgressBar. How can I do this

4条回答
  •  无人及你
    2021-01-30 15:07

    Use the following layout as the action view for the action bar menu item.

    actionbar_refresh_progress.xml

    
        
    
    

    Then

    menuItem.setActionView(R.layout.actionbar_refresh_progress);
    

    Works across Gingerbread and the rest like a charm. Note that I have used dimension from support action bar for compatibility. You can use @dimen/action_button_min_width instead for ICS and up.

    Source: https://code.google.com/p/iosched/source/browse/android/res/layout/actionbar_indeterminate_progress.xml?r=f4fd7504d43b25a75cc23b58d6f844f3553b48c3

提交回复
热议问题