标签:
1 @Override 2 protected void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 setContentView(R.layout.activity_main); 5 6 btn = (Button)findViewById(R.id.btn); 7 builder = new AlertDialog.Builder(this); 8 builder.setTitle("提示框"); 9 builder.setIcon(R.drawable.ic_launcher); 10 builder.setMessage("确定删除吗"); 11 builder.setNegativeButton("取消", new DialogInterface.OnClickListener(){ 12 @Override 13 public void onClick(DialogInterface arg0, int arg1) { 14 Toast.makeText(MainActivity.this, "取消了删除", 1).show(); 15 } 16 17 }); 18 builder.setPositiveButton("确定", new DialogInterface.OnClickListener(){ 19 @Override 20 public void onClick(DialogInterface arg0, int arg1) { 21 Toast.makeText(MainActivity.this, "已经删除", 1).show(); 22 } 23 24 }); 25 btn.setOnClickListener(new OnClickListener() { 26 @Override 27 public void onClick(View arg0) { 28 builder.show(); 29 } 30 }); 31 }
熟悉AndroidAPI系列12——AlertDialog和Toast
标签:
原文地址:http://www.cnblogs.com/lya-nju/p/4193315.html