0

I put a progress bar (circular) in the action bar with the following code:

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

and in the java code:

public void onProgressChanged(WebView view, int progress) 
        {  
            if (progress<100)
            {
               progressBar.setVisibility(ProgressBar.VISIBLE);
            }
            else if (progress==100)
            {
               progressBar.setVisibility(ProgressBar.GONE);
            }
            progressBar.setProgress(progress);  
        }   

However, the progress bar will not disappear even after the webpage has loaded, and I have no clue why.

Can anyone help? Thank you.

jyoonPro
  • 1,661
  • 1
  • 16
  • 41
  • Please see the answer to the similar question [here][1] [1]: http://stackoverflow.com/questions/9157504/put-a-progressbar-on-actionbar – Oleg Kleiman Feb 03 '15 at 20:42

2 Answers2

1
progressBar.setVisibility(view.GONE);

or

progressBar.setVisibility(2);

http://developer.android.com/reference/android/view/View.html#attr_android:visibility

HarshMarshmallow
  • 1,007
  • 11
  • 23
  • The setvisibility function only takes a number from 0-2, which makes me think that this code is not in a handler or async task. The visibility needs to be set in the onpostexecute() method like giorgos says below – HarshMarshmallow Feb 04 '14 at 16:09
0

It should be better if you put the code in the onPostExcecute() method. You gain performance.

georgeok
  • 5,321
  • 2
  • 39
  • 61