比Toast更友好的对话框AlertDialog
来源:互联网 发布:花生壳软件下载 编辑:程序博客网 时间:2024/04/27 18:38
在调试过程中往往会弹出一个提示来提醒一个操作的状态,使用Toast时是会自动消失的,可能导致无法看到需要的信息。
而AlertDialog则是可以交互的对话框,使用起来更友好一些,一行代码的写法(与Toast相似的简洁哦~)
new AlertDialog.Builder(this).setTitle("Error").setMessage("Detail message.").setPositiveButton("OK", null).show();
当然还可以写的更复杂些:
new AlertDialog.Builder(this)
.setTitle("Warning")
.setMessage("Sure to reboot?")
.setNegativeButton("Cancel", null)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String cmd = "su -c reboot";
try {
Runtime.getRuntime().exec(cmd);
} catch (Exception e){
Toast.makeText(getApplicationContext(), "Error! Fail to reboot.", Toast.LENGTH_SHORT).show();
}
}
})
.show();
- 比Toast更友好的对话框AlertDialog
- SnackBar的简单使用(类似于Toast,但比Toast更强大)
- 友好的页面“确认对话框”
- alertDialog对话框的实现
- AlertDialog对话框的使用
- AlertDialog的列表对话框
- AlertDialog的复选对话框
- AlertDialog的对话框模式
- AlertDialog对话框的使用
- 对话框AlertDialog的使用
- Android界面设计之对话框——定制Toast、AlertDialog
- Android界面设计之对话框——定制Toast、AlertDialog
- 改善DataGrid的默認分頁使其更友好
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- Android中AlertDialog和Toast的使用
- 深入GridView、Toast的用法、AlertDialog
- TagSupport使用入门
- Qt 菜单操作详解
- row_number() over (partition by....order by...)用法
- Android开发中的技术细节
- android布局文件详解
- 比Toast更友好的对话框AlertDialog
- cordic算法计算sin和cos
- 自订标签库--TagSupport详解
- 第二次当面试官
- Delphi制作DLL
- Gcc How to
- Velocity入门
- eclipse 中的 jar file 和 runnable jar file的区别
- 最全的Java中正则表达式验证日期格式