标签:设置 finish dial ast star 事件 miss read exception
1.Toast信息提示框
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ToastImpl.this,
"短时间", Toast.LENGTH_SHORT).show();
}
});
2.对话框(Dislog)
1>警告框(AlertDialog)
Dialog ad=new AlertDialog.Builder(this)
.setTitle("警告是否删除?") //设置标题
.setIcon(R.drawable.icon) //设置显示图片
.setMessage("确定要删除信息吗?") //设置内容
.create();
ad.show();
2>进度处理对话框
bt1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final ProgressDialog pDialog=ProgressDialog.show(Day09.this, "搜索", "正在加载中....");
new Thread(){
public void run(){
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}finally{
pDialog.dismiss();
}
}
}.start();
pDialog.show();
}
});
3.>对话框操作事件
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Dialog ad=new AlertDialog.Builder(ToastImpl.this)
.setIcon(R.drawable.icon)
.setTitle("退出?")
.setMessage("是否退出")
.setNegativeButton("确定",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ToastImpl.this.finish();
}
})
.setPositiveButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNeutralButton("查看详情", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
ad.show();
}
});
4.>对话框退出提示
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK){
Dialog dialog=new AlertDialog.Builder(ToastImpl.this)
.setIcon(R.drawable.sss)
.setTitle("退出")
.setMessage("是否退出")
.setNegativeButton("确认",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ToastImpl.this.finish();
}
}).create();
dialog.show();
return false;
}
return super.onKeyDown(keyCode, event);
}
标签:设置 finish dial ast star 事件 miss read exception
原文地址:http://www.cnblogs.com/ch123456/p/6891004.html