0
我的應用程序仍在顯示處理狀態,但我轉到另一個屏幕並註銷仍在處理的進程對話框沒有停止它。登錄後和註銷時,進程對話框不會停止
當我按在登錄頁面登錄按鈕,我用這個代碼:
btnLogin.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
showProgress();
postLoginData();
}
});
public void postLoginData() {
if (pin.getTextSize() == 0 || mobile.getTextSize() == 0) {
AlertDialog.Builder altDialog = new AlertDialog.Builder(this);
altDialog.setMessage("Please Enter Complete Information!");
} else {
Intent i = new Intent(this.getApplicationContext(),
AgAppMenu.class);
Bundle bundle = new Bundle();
bundle.putString("mno", mobile.getText().toString());
bundle.putString("pinno", pin.getText().toString());
i.putExtras(bundle);
startActivity(i);
}
}
private void showProgress() {
myProgressDialog = ProgressDialog.show(LoginScreen.this, null, "Processing please wait...", true);
}
如果我使用myProgressDialog.dismiss() 在此位置 意圖I =新意圖(this.getApplicationContext(),AgAppMenu.class); \t \t \t Bundle bundle = new Bundle(); \t \t \t bundle.putString(「mno」,mobile.getText()。toString()); \t \t \t bundle.putString(「pinno」,pin.getText()。toString()); \t \t \t \t \t i.putExtras(bundle); \t \t \t myProgressDialog.dismiss(); \t \t \t startActivity(i); processdailog沒有顯示 –
因爲它太快了,showProgress();然後myProgressDialog.dismiss(); ,或者你可以使用postDelayed在一定時間後關閉它。 –
帶有Runnable的處理程序'postDelayed'可在一定的時間內解除它。 –