简体   繁体   English

ActionBar Sherlock-显示一个变成刷新按钮的ProgressBar

[英]ActionBar Sherlock - Display a ProgressBar that turns into a Refresh Button

I have Integrated an ABS into my application. 我已经将ABS集成到我的应用程序中。 I have an inflated MenuBar that contains a Refresh button. 我有一个膨胀的MenuBar,其中包含一个Refresh按钮。 When i click on the refresh button, it should turn into a ProgressBar, and once my refresh call is completed, it should turn back into a Refresh Button. 当我单击刷新按钮时,它应该变成一个ProgressBar,并且在完成刷新调用后,它应该又变成一个刷新按钮。 How can i do this ? 我怎样才能做到这一点 ?

Kind Regards, 亲切的问候,

you can do it by making the menu have a framelayout or any other layout you want and placing a button and a progress bar on it ...this progress bar should be hidden by default .... 您可以通过使菜单具有所需的框架布局或任何其他布局并在其上放置按钮和进度栏来实现此目的...默认情况下应隐藏此进度栏....

at runtime when u click on the refresh button u can toggle the visibility of the progressbar and button ...when the work of the progress bar is done...again do the same trick.... 在运行时,当您单击刷新按钮时,您可以切换进度条和按钮的可见性...当进度条完成工作时...再次执行相同的操作...

Put your button inside a FrameLayout and put also inside this framelayout a progressbar with android:visibility="gone" , then after loading your data get this progressbar and set the button visibility as visible and the progressbar as gone. 将您的按钮放在FrameLayout内,并在此framelayout内放置一个带有android:visibility="gone"的进度条,然后在加载数据后获得此进度条,并将按钮可见性设置为可见,将进度条设置为消失。

Some pseudo code: 一些伪代码:

private void onDataLoaded(){
   ProgressBar pb = getSupportActionBar.getCustomView().findViewbyId(R.id.pb);
   pb.setVisibility(View.GONE);
   Button refresh = getSupportActionBar.getCustomView().findViewbyId(R.id.refresh);
   pb.setVisibility(View.VISIBLE);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM