对话框
来源:互联网 发布:淘宝网店卖商品收费吗 编辑:程序博客网 时间:2024/05/21 18:36
return new AlertDialog.Builder(this)
.setTitle(R.string.rgb_summary)
.setPositiveButton(R.string.rgb_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mView.mTimer.cancel();
Utils.writeResult("pass");
finish();
}
})
.setNegativeButton(R.string.rgb_no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mView.mTimer.cancel();
Utils.writeResult("fail");
dialog.dismiss();
}
}).create();
}
或
AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setTitle(R.string.factory_title);
ad.setMessage(R.string.factory_message);
ad.setPositiveButton(R.string.factory_title,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int i) {
Intent intent = new Intent(mContext,
ChooseActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
BaseApplication appState = (BaseApplication)BootActivity.this.getApplication();
appState.startService();
finish();
}
});
ad.setNegativeButton(R.string.project_title,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(mContext, MainProject.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
dialog.dismiss();
}
});
ad.show();
自定义对话框:
LayoutInflater inflater1 = getLayoutInflater();
View view1 = inflater1.inflate(R.layout.userdefinedtoast, (ViewGroup) findViewById(R.id.toast_layout));
TextView txtView_Title1 = (TextView) view1.findViewById(R.id.txt_Title);
txtView_Title1.setText("chongxinmingming");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view1);
AlertDialog dialog = builder.create();
dialog.show();
注:默认情况下,在点击dialog以外的屏幕时,dialog会消失的解决办法
dialog.setCancelable(false);
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- 对话框
- validatabox 验证表单改中文
- iptables添加删除规则
- 一些常用的T_SQL字符串处理函数
- C#泛型实现流中C/C++格式的struct数据的通用读取方法
- AIX更换rootvg硬盘
- 对话框
- 数字证书的原理与实现
- Linux下的调试工具
- js写入和读取Cookie
- 服务器端网络编程语言PK(网络评论)
- 2011-7-29 15:12:24
- 存储方式与介质对性能的影响
- Linux-HA 入门指南(引用)
- Android:点亮屏幕,和取消点亮屏幕