Reputation: 2327
I have a code like this:
In a Button Click I wrote this Code:
new Loadiing().execute();
It takes to the AsyncTask class That I created, My class Looks Like:
public class Loadiing extends AsyncTask<Void,Void,Void>{
ProgressDialog d= new ProgressDialog(Main.this);
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
ProgressDialog.show(Main.this, "", "Loading");
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
**A method which returns some data in a arrayadapter and sets it;**
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
d.dismiss();
}
}
but it is just starting an alert dialog, nothing is done in the background and also the dialog is not being dismissed, what to do?
Upvotes: 0
Views: 92
Reputation: 109237
This should be,
d.show();
instead of, ProgressDialog.show(Main.this, "", "Loading");
Update: In your case,
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
d.setTitle("Loading");
d.show();
}
Upvotes: 2