zoukankan      html  css  js  c++  java
  • 【Demo 0002】Android 提醒框

    本章学习要点:

    //==: Alert Dialog

    void showAlertDialog() {

    final Builder builder = new AlertDialog.Builder(this);

    builder.setTitle("AlertDialog");

    builder.setMessage("This is a alert message!");

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

    @Override

    public void onClick(DialogInterface dialog, int which) {

     

    }

    });

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

    @Override

    public void onClick(DialogInterface dialog, int which) {

     

    }

     

    });

    AlertDialog alertDialog = builder.create();

    alertDialog.show();

    }

     

    //==: Option Alert Dialog

    void showOptionDialog() {

     

    final String[] items = {"Apple", "Banana", "Pear", "Tomato" };

     

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setTitle("Which fruit do you like?");

    builder.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {

     

    @Override

    public void onClick(DialogInterface dialog, int which) {

    StringBuilder sb = new StringBuilder();

    sb.append(items[which]);

    sb.append(" is very good!");

     

    Toast toast = Toast.makeText(getApplicationContext(), sb.toString(), Toast.LENGTH_SHORT);

    toast.show();

    }

    });

     

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

     

    @Override

    public void onClick(DialogInterface dialog, int which) {

    return;

    }

    });

     

    AlertDialog alertDialog = builder.create();

    alertDialog.show();

    }

     

    //==: Toast Dialog 

    void showToastDialog() {

    Toast toast = Toast.makeText(getApplicationContext(), "This is a toast dialog", Toast.LENGTH_LONG);

    toast.show();

    }

  • 相关阅读:
    LoadRunner的Capture Level说明
    LoadRunner Click&script 录制Tips
    LoadRunner虚拟用户协议脚本语言矩阵表
    LoadRunner 测试 AJAX
    如何创建自定义性能计数器
    8个批量样本数据生成工具
    JDBC性能优化
    使用Servlet为LoadRunner提供全局连续唯一数
    LoadRunner11测试Weblogic的问题
    如何让Fiddler捕获并记录HTTPS包?
  • 原文地址:https://www.cnblogs.com/ztercel/p/3415054.html
Copyright © 2011-2022 走看看