Is it possible to add progressbar to ActionBarSherlock? I need to show and hide it in particular time. But it has to be located inside ActionBarSherlock.
Code of my
For full compatibility you should use:
setSupportProgressBarIndeterminateVisibility(true);
Here is an example:
public class MyActivity extends SherlockFragmentActivity {
//...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.my_layout);
//...
setSupportProgressBarIndeterminateVisibility(true);
}
}
Yes. You can add a ProgressBar to an ActionBar using ABS.
This is an extract from the source provided below, if the solutions helps, +1 the original poster ;-)
In your onCreate()
method, add this piece of code:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
And when you are done with the task that you need to display the ProgressBar for, hide the ProgressBar using this code:
setProgressBarIndeterminateVisibility(false);
Credit: https://stackoverflow.com/a/9157874/450534
Yes, you can, ABS has such feature. Next piece of code is from Demos sample app of ABS:
public class Progress extends SherlockActivity {
Handler mHandler = new Handler();
Runnable mProgressRunner = new Runnable() {
@Override
public void run() {
mProgress += 2;
//Normalize our progress along the progress bar's scale
int progress = (Window.PROGRESS_END - Window.PROGRESS_START) / 100 * mProgress;
setSupportProgress(progress);
if (mProgress < 100) {
mHandler.postDelayed(mProgressRunner, 50);
}
}
};
private int mProgress = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
//This has to be called before setContentView and you must use the
//class in com.actionbarsherlock.view and NOT android.view
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.progress);
findViewById(R.id.go).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (mProgress == 100) {
mProgress = 0;
mProgressRunner.run();
}
}
});
}
}
this sample you can find in samples\demos\ directory of ABS (Progress.java in eclipse workspace)