1
我试图通过创建一系列可以在Android中执行的对话框菜单来模拟Android中的USSD交互。我试图让它在对话框之间有一个表示“USSD代码正在运行...”的进度对话框。但是,当点击肯定按钮时,当我尝试使用可运行定时器运行ProgressDialog并按照它进行操作时通过下一个名为FirstTimeUser的对话框,即使我尝试将它们与另一个计时器分开,它们也会将一个层叠到另一个上面。我如何让它们连续运行而不是同时运行?下面的代码片段:在对话框之间显示ProgressDialog
USSDprogressDialog();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
final View dialogView = inflater.inflate(R.layout.number_response_dialog, null);
builder.setView(dialogView)
.setMessage(R.string.MainMenuText)
// Add action buttons
.setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// Send number to next dialog
String choice = getMenuChoice(dialogView);
if (choice.equals("5")) {
USSDprogressDialog();
FirstTimeUse();
} else {
//Do nothing
}
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// End session
}
});
AlertDialog dialog = builder.create();
dialog.show();
与进步具有定时对话框:
public void USSDprogressDialog() {
final ProgressDialog progress = new ProgressDialog(this);
progress.setMessage("USSD code running...");
progress.show();
Runnable progressRunnable = new Runnable() {
@Override
public void run() {
progress.cancel();
}
};
Handler handler = new Handler();
handler.postDelayed(progressRunnable, 2000);
}
任何建议将受到欢迎!谢谢!
我试图包括FirstTimeUse progresscancel,如你所建议的那样,工作!但是现在我又遇到了另一个问题,那就是我需要制作USSDProgressDialog泛型,以便能够将它包含在所有对话框之间,并且我有很多对话框。不过,我会继续努力。谢谢!! – notchopra
看看第二句 - 让USSDprogressDialog收到一个可运行的 –
啊!我明白你的意思了。谢谢!! – notchopra