Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android how to show progress dialog on snackBar?

Is there way to show progress dialog on snackBar while getting data from server for pagination inside AsyncTask.If is this possible then how to do this.Please give suggestions.

like image 327
Sachin Mandhare Avatar asked Feb 11 '16 07:02

Sachin Mandhare


People also ask

What is the use of snackbar in Android?

Snackbars provide lightweight feedback about an operation. They show a brief message at the bottom of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.

When to use Snackbars?

Usage link Snackbars inform users of a process that an app has performed or will perform. They appear temporarily, towards the bottom of the screen. They shouldn't interrupt the user experience, and they don't require user input to disappear.


1 Answers

For new design library:

if you want to show progressBar in left side:

 Snackbar bar = Snackbar.make(root, R.string.data_updating, Snackbar.LENGTH_INDEFINITE);
        ViewGroup contentLay = (ViewGroup) bar.getView().findViewById(android.support.design.R.id.snackbar_text).getParent();
        ProgressBar item = new ProgressBar(context);
        contentLay.addView(item,0);
        bar.show();

or in right side:

 Snackbar bar = Snackbar.make(root, R.string.data_updating, Snackbar.LENGTH_INDEFINITE);
        ViewGroup contentLay = (ViewGroup) bar.getView().findViewById(android.support.design.R.id.snackbar_text).getParent();
        ProgressBar item = new ProgressBar(context);
        contentLay.addView(item);
        bar.show();
like image 86
Witoldio Avatar answered Oct 30 '22 18:10

Witoldio