I have a alertdialog in which data coming from internet. Sometimes due to internet connectivity data comes late. so i want progress bar before spinner shows itself. while getting data i have written this.
final String[] List= new String{ 'abc', 'def'};
ArrayList<String> ListArray = new ArrayList<String>();
ListArray.addAll(Arrays.asList(List));
ListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, ListArray);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Data");
builder.setAdapter(ListAdapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
txtExec.setText(ClientList[item]);
}
});
AlertDialog alert = builder.create();
alert.show();
ProgressDialog dialog = new ProgressDialog(this);
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
So how do i adjust progessDialog before alert dialog box?
You should load the data from the internet in a thread or an AsyncTask.
here you have a small article describing the possibilities.
I recommend the AsyncTask method, I post you a little pseudocode on how to do it, refer to the docs for more details on how you can pass the data you load in the
doInBackgroundmethod to theonPostExecutefor example.