Reputation: 34507
Hello I am having action bar which I made using appcompat library in android. It looks like
When I click on the refresh menu item then I here show the progress bar and it is displaying perfectly
menuItem.setActionView(R.layout.progressbar);
menuItem.expandActionView();
progressbar.xml
<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ProgressBar>
but after my task done in async task I am doing to stop it in onPostExecute
like below which is not working, means progress bar still executing after that also. I want to hide it and show refresh button after this process complete but it is not working currently
menuItem.collapseActionView();
menuItem.setActionView(null);
Any idea what it is wrong ?
Upvotes: 1
Views: 597
Reputation: 8473
I can guess, you've forgot to invalidate action bar. If you, then just call invalidateOptionsMenu()
. And see the magic ;)
menuItem.collapseActionView();
menuItem.setActionView(null);
YourActivity.this.invalidateOptionsMenu();
Upvotes: 3