为什么不出现 ProgressDialog?
我的 Android 应用程序出现问题。当用户单击按钮时我需要一个进度对话框。问题是这个进度对话框没有出现,我不明白问题出在哪里。谁能帮助我吗?这是我的代码:
public void btnSend_onClick(View c) {
dialogwait = ProgressDialog.show(SendPhoto.this, "",
"Loading. Please wait...", true); dialogwait.show();
//dialogwait = ProgressDialog.show(this, "Loading..", "Please wait...", true, false);
Handler message = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
}
dialogwait.cancel();
}
};
message.sendEmptyMessageDelayed(0, 3 * 1000);
surname = eTxtSurname.getText().toString();
name = eTxtName.getText().toString();
email1 = eTxtEmail.getText().toString();
phone1 = eTxtPhone.getText().toString();
shop_id = Singleton.getInstance().getShop();
boolean ok = isEmailValid(eTxtEmail.getText().toString());
System.out.println("ok e" + ok);
System.out.println("ok e" + surname);
System.out.println("ok e" + name);
System.out.println("ok e" + email1);
System.out.println("ok e" + phone1);
sendimg.setVisibility(View.INVISIBLE);
if ((surname.isEmpty()) || (name.isEmpty()) || (email1.isEmpty())
|| (phone1.isEmpty())) {
Toast.makeText(this, error_complete, Toast.LENGTH_SHORT).show();
sendimg.setVisibility(View.VISIBLE);
} else if (ok != true) {
dialogwait.cancel();
Toast.makeText(getBaseContext(), email_valid, Toast.LENGTH_SHORT)
.show();
sendimg.setVisibility(View.VISIBLE);
} else {
String r = executeMultiPartPost(surname, name, email1, phone1,
shop_id);
if (r.equals("ok")) {
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(sent_ok);
alertDialog.setMessage(alertmsg);
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Intent i = new Intent(getBaseContext(),
com.Xperiaproject.Participe.class);
startActivity(i);
return;
}
});
alertDialog.show();
}
}
}
I have a problem in my android app. I need a progressdialog when the user click a button. The problem is that this progressdialog doesn't appear and I don't understand where is the problem. Can anyone help me? This is my code:
public void btnSend_onClick(View c) {
dialogwait = ProgressDialog.show(SendPhoto.this, "",
"Loading. Please wait...", true); dialogwait.show();
//dialogwait = ProgressDialog.show(this, "Loading..", "Please wait...", true, false);
Handler message = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
}
dialogwait.cancel();
}
};
message.sendEmptyMessageDelayed(0, 3 * 1000);
surname = eTxtSurname.getText().toString();
name = eTxtName.getText().toString();
email1 = eTxtEmail.getText().toString();
phone1 = eTxtPhone.getText().toString();
shop_id = Singleton.getInstance().getShop();
boolean ok = isEmailValid(eTxtEmail.getText().toString());
System.out.println("ok e" + ok);
System.out.println("ok e" + surname);
System.out.println("ok e" + name);
System.out.println("ok e" + email1);
System.out.println("ok e" + phone1);
sendimg.setVisibility(View.INVISIBLE);
if ((surname.isEmpty()) || (name.isEmpty()) || (email1.isEmpty())
|| (phone1.isEmpty())) {
Toast.makeText(this, error_complete, Toast.LENGTH_SHORT).show();
sendimg.setVisibility(View.VISIBLE);
} else if (ok != true) {
dialogwait.cancel();
Toast.makeText(getBaseContext(), email_valid, Toast.LENGTH_SHORT)
.show();
sendimg.setVisibility(View.VISIBLE);
} else {
String r = executeMultiPartPost(surname, name, email1, phone1,
shop_id);
if (r.equals("ok")) {
alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(sent_ok);
alertDialog.setMessage(alertmsg);
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
Intent i = new Intent(getBaseContext(),
com.Xperiaproject.Participe.class);
startActivity(i);
return;
}
});
alertDialog.show();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用:
否则使用 Asyntask (Adil 的评论)
This is working for me:
otherwise use Asyntask (comment of Adil)