android how to show progress dialog on snackBar?

Sachin Mandhare picture Sachin Mandhare · Feb 11, 2016 · Viewed 9.6k times · Source

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.

Answer

Witoldio picture Witoldio · Mar 9, 2017

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();