Android:AlertDialog对话框

1、简单的ALertDialog:

Android:AlertDialog对话框

Dialog alertDialog = new AlertDialog.Builder(this)
.setTitle("标题")
.setMessage("内容")
.setIcon(R.drawable.ic_launcher).create();
alertDialog.show();

2、带按钮的ALertDialog

Android:AlertDialog对话框

public class MainActivity extends Activity {

    okListener oklistener=new okListener();
noListener nolistener =new noListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.demo);
Dialog alertDialog = new AlertDialog.Builder(this).setTitle("标题")
.setMessage("内容").setIcon(R.drawable.ic_launcher)
.setPositiveButton("确定", oklistener)
.setNegativeButton("取消", nolistener)
.create();
alertDialog.show();
} public class okListener implements DialogInterface.OnClickListener{ @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub }
} public class noListener implements DialogInterface.OnClickListener{ @Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub }
} }

相关文章:

Android详细的对话框AlertDialog.Builder使用方法

Android:实现退出确认对话框

上一篇:Python黑帽编程 3.2 ARP监控


下一篇:无意之间发现的Servlet3.0新特性@WebServlet