Jac*_*ine 12 java user-interface android
当我意识到在Android的进度对话框或微调器中没有取消按钮时,我正面临一个类似于这个人(从2008年1月开始)的经历.现在是2009年7月,我刚安装了Android的蛋糕版.这件事改变了吗?如果没有,你是否在对话框中添加了取消按钮,你是如何做到的?
chi*_*ich 16
不确定整个取消按钮...我听说过onCancel()方法没有正确触发的报告.我的解决方案只是在对话框上创建一个普通按钮,并在按下按钮时调用返回.
private void createCancelProgressDialog(String title, String message, String buttonText)
{
cancelDialog = new ProgressDialog(this);
cancelDialog.setTitle(title);
cancelDialog.setMessage(message);
cancelDialog.setButton(buttonText, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// Use either finish() or return() to either close the activity or just the dialog
return;
}
});
cancelDialog.show();
}
Run Code Online (Sandbox Code Playgroud)
然后只需使用活动中其他地方的简单调用方法
createCancelProgressDialog("Loading", "Please wait while activity is loading", "Cancel");
Run Code Online (Sandbox Code Playgroud)
相当简单的解决方案,但它确实有诀窍;)也只是要注意cancelDialog是一个活动擦除变量,如果你不需要从其他地方调用它,那么你应该能够逃脱只是将变量的范围限制为那种方法.
| 归档时间: |
|
| 查看次数: |
10070 次 |
| 最近记录: |