私は、次のコードProgressDialog新しいアクティビティAsynctaskが表示されません、なぜですか?
public class removeDialog extends AsyncTask<Void, Void, Void> {
Context c;
ProgressDialog asyncDialog;
String page;
public removeDialog(Context c, String page) {
this.c = c;
this.page = page;
asyncDialog = new ProgressDialog(c);
}
@Override
protected void onPreExecute() {
//set message of the dialog
asyncDialog.setTitle("Please wait");
asyncDialog.setMessage("Loading...");
asyncDialog.setCancelable(false);
//show dialog
asyncDialog.show();
if (page == "algemeneVoorwaarden") {
Intent intent = new Intent(c, algemeneVoorwaarden.class);
c.startActivity(intent);
}
if (page == "contact") {
Intent intent = new Intent(c, contactTest.class);
c.startActivity(intent);
}
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... arg0) {
//don't touch dialog here it'll break the application
//do some lengthy stuff like calling login webservice
return null;
}
@Override
protected void onPostExecute(Void result) {
//hide the dialog
asyncDialog.dismiss();
super.onPostExecute(result);
}
}
私が試した初めてでAsyncTaskクラスを作った:私は、ProgressDialogを見る初めての を、私は、私は何を取得アクティビティを開きたい二度目。
私は試してみました: 初めて試してもProgressDialogは表示されません。
私は、AsyncTaskクラスのコードを自分のコードを実行します。それが機能しない理由
voorwaarden.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new removeDialog(c, "algemeneVoorwaarden").execute();
}
});
誰かが知っていますか?私を助けてください。
AsyncTask派生クラスの名前は 'removeDialog'ですか?あなたのクラスのヘッダーを投稿できればいいですね。 – Milack27
これはクラスの名前です。 – sander
あなたの 'onPreExecute'では、ダイアログを表示して新しいアクティビティを開始しています。私は間違っているかもしれませんが、あなたのダイアログは最初のアクティビティの中に表示されていると思います。新しいアクティビティを開始すると、ダイアログが残されます。 – Milack27