创建提示对话框
来源:互联网 发布:编程单引号怎么打出来 编辑:程序博客网 时间:2024/05/17 03:18
public class Alerts {
public static void showAlert(String message,Context ctx){
//提示消息
AlertDialog.Builder builder=new AlertDialog.Builder(ctx);
builder.setTitle("Alert Window");
builder.setMessage(message);
//button 的监听
EmptyListener pl=new EmptyListener();
builder.setPositiveButton("ok",pl);
AlertDialog ad=builder.create();
ad.show();
}
}
public class EmptyListener implements android.content.DialogInterface.OnClickListener{
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}
//当选择一个 menu时,显示该提示消息。
if(item.getItemId()==R.id.menu_testpick){
Alerts.showAlert("Simple Sample Alert", this);
}
二、提示对话框实例二
LayoutInflater li=LayoutInflater.from(ctx);
View view=li.inflate(R.layout.prompt_layout, null);
AlertDialog.Builder builder=new AlertDialog.Builder(ctx);
builder.setTitle("prompt");
builder.setView(view); //将xml形成的界面输入给对话框
PromptListener pl=new PromptListener(view); //传递view值alert的类
builder.setPositiveButton("ok",pl);
builder.setNegativeButton("cancel", pl);
AlertDialog ad=builder.create();
ad.show();
return pl.getPromptReply(); //点击后返回的值
public void onClick(DialogInterface dialog, int buttonId) {
// TODO Auto-generated method stub
//点击ok按钮后处理的方法
if(buttonId==DialogInterface.BUTTON1){
promptReply=getPromptText();
}else{
promptReply=null;
}
}
//获取界面的值
private String getPromptText(){
EditText et=(EditText)promptDialogView.findViewById(R.id.editText_prompt);
return et.getText().toString();
}
- 创建提示对话框
- JS创建自动提示的对话框
- Android学习:不再提示对话框(创建自定义对话框)
- vs2010/MFC 非模态对话框创建以及修改static提示内容
- 使用AlertDialog创建简单的对话框1-显示提示消息的对话框
- 【Android开发】消息提示框与对话框-使用AlertDialog创建对话框
- 创建对话框
- 创建对话框
- 创建对话框
- 弹出一个提示对话框
- 对话框CToolBarCtrl添加提示
- ajax+提示对话框
- 弹出提示对话框
- 提示对话框(MessageBox)
- 信息提示对话框
- 封装提示对话框
- js+dom提示对话框
- bat弹出提示对话框
- 第一次发博客文章
- “服务器推”技术的应用
- 百练3727摘花生
- iPad软件提交注意事项
- IP报文结构浅析
- 创建提示对话框
- 赛灵思宣布收购 AUTOESL
- VC/MFC 不同进程间的消息通信与数据(字符串)发送
- ABAP概述
- WPF error message: Partial declaration must not specify different base classes
- SSO单点登录解决方案[转载]
- 怎样为人处事的原则和方法
- 揭开正则表达式的神秘面
- 在线程中控制进度条