zoukankan      html  css  js  c++  java
  • Android 开发笔记___alertDialog

     1 public class AlertActivity extends AppCompatActivity implements OnClickListener {
     2 
     3     private TextView tv_alert;
     4 
     5     @Override
     6     protected void onCreate(Bundle savedInstanceState) {
     7         super.onCreate(savedInstanceState);
     8         setContentView(R.layout.activity_alert);
     9         findViewById(R.id.btn_alert).setOnClickListener(this);
    10         tv_alert = (TextView) findViewById(R.id.tv_alert);
    11     }
    12 
    13     @Override
    14     public void onClick(View v) {
    15         if (v.getId() == R.id.btn_alert) {
    16             AlertDialog.Builder builder = new AlertDialog.Builder(this);
    17             builder.setTitle("尊敬的用户");
    18             builder.setMessage("你真的要卸载我吗?");
    19             builder.setPositiveButton("残忍卸载", new DialogInterface.OnClickListener() {
    20                 @Override
    21                 public void onClick(DialogInterface dialog, int which) {
    22                     tv_alert.setText("虽然依依不舍,还是只能离开了");
    23                 }
    24             });
    25             builder.setNegativeButton("我再想想", new DialogInterface.OnClickListener() {
    26                 @Override
    27                 public void onClick(DialogInterface dialog, int which) {
    28                     tv_alert.setText("让我再陪你三百六十五个日夜");
    29                 }
    30             });
    31             AlertDialog alert = builder.create();
    32             alert.show();
    33         }
    34     }
    35 
    36 }
  • 相关阅读:
    含有tuple的list按照tuple中的某一位进行排序
    python
    Python代码追踪(类似于bash -x的效果)
    cinder swift的区别
    C#中Main函数为什么要static
    C#编程.函数.委托
    C#编程.函数.Main()函数
    C#编程.函数.参数
    typedef int a[10];怎么解释?
    C#的DateTime得到特定日期
  • 原文地址:https://www.cnblogs.com/alimjan/p/7117097.html
Copyright © 2011-2022 走看看