I'm trying to add a progress bar to my actionBar. I'm talking about the spinning circle. I did a request and tried to set is vissible, but nothing happens. I have read many likely questions but is still couldn't figure out what i'm doing wrong.
My code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);//Above setContentView, very important
setContentView(R.layout.activity_main);
//...other stuff
}
In an other method which i don't call in on create.(It's an onClick method)
public void plus(View view){
setProgressBarIndeterminateVisibility(true);//Nothing happens
//...other stuff
}
I do not understand what's wrong, please help me.
NOTE: I never set it to false
Edit: I tried mmlooloo second part, but absolutly noting happend. Not even part 3. So I tried part 4, but i gave me an exception.
"This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead."
I removed the Window.FEATURE_ACTION_BAR request, but it gave me the same exception. I don't think i need to set windowActionBar to false, but I did and it still gave me the same exception.
Any other options?
First:
Second:
you must use:
instead of
because you extends
ActionBarActivity
. (because you are usingsupportRequestWindowFeature
instead ofrequestWindowFeature
)Third:
If it crashes this is a known issue. If your library is updated sorry but it is now just a no-op:
Fourth:
My solution:
use toolbar with progressBar widget:
Layouts:
activity_main.xml
and
toolbar.xml