Dialog dialog = new AlertDialog.Builder(this).setTitle("对话框").setMessage("this is msg info").setIcon(R.drawable.ic_launcher).create();
dialog.show();
package com.example.demo15alertdialog;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button; public class MainActivity extends Activity {
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); this.button=(Button)super.findViewById(R.id._btn); this.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dialog dialog = new AlertDialog.Builder(MainActivity.this).setTitle("对话框")
.setMessage("this is msg info")
.setIcon(R.drawable.ic_launcher)
.setPositiveButton("Delete",new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialogInterface,int whichButton) {
}})
.setNeutralButton("Show Detail",new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialogInterface,int whichButton) {
}})
.setNegativeButton("Cancel",new DialogInterface.OnClickListener(){public void onClick(DialogInterface dialogInterface,int whichButton) {
}})
.create();
dialog.show();
}
});
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }

demo15 AlertDialog的更多相关文章

  1. Stack Overflow 排错翻译 - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder

    Stack Overflow 排错翻译  - Closing AlertDialog.Builder in Android -Android环境中关闭AlertDialog.Builder 转自:ht ...

  2. Android中的AlertDialog使用示例五(自定义对话框)

    在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,AlertDialog实现方法为建造者模式. ...

  3. android 弹出AlertDialog的学习案例

    我在编写的时候,测试的关键代码: AlertDialog.Builder builder=new AlertDialog.Builder(MainPointListActivity.this); bu ...

  4. The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder is not applicable for the arguments

    The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i ...

  5. setView的AlertDialog在受到二次点击后出错

    错误报告: 10-21 13:11:16.009: E/AndroidRuntime(27937): FATAL EXCEPTION: main10-21 13:11:16.009: E/Androi ...

  6. 关于AlertDialog.Builder(Context context)中所应传入的context

    错误报告: 10-20 14:34:46.565: E/AndroidRuntime(23098): FATAL EXCEPTION: main10-20 14:34:46.565: E/Androi ...

  7. 安卓 自定义AlertDialog对话框(加载提示框)

    AlertDialog有以下六种使用方法: 一.简单的AlertDialog(只显示一段简单的信息) 二.带按钮的AlertDialog(显示提示信息,让用户操作) 三.类似ListView的Aler ...

  8. Android AlertDialog去除黑边白边自定义布局(转)

    LayoutInflater inflater = this.getLayoutInflater(); View view = inflater.inflate(R.layout.test_alert ...

  9. Android开发2:事件处理及实现简单的对话框(Toast,AlertDialog,Snackbar,TextInputLayout的使用)

    前言 啦啦啦~又要和大家一起学习Android开发啦,博主心里好激动哒~ 在上篇博文中,我们通过线性布局和基础组件的使用,完成了一个简单的学生课外体育积分电子认证系统的界面,本篇博文,将和大家一起熟悉 ...

随机推荐

  1. https centos6 and 7

    keytool -printcert -sslserver 10.10.192.90:8443 -rfc >nexus.crt 通过  openssl 将 证书转换为 .pem格式的 通过以下命 ...

  2. yum-config-manager YUM安装遭遇: [Errno 256] No more mirrors to try CentOS yum之$releasever和$basearch

    YUM安装遭遇: [Errno 256] No more mirrors to try createrepo 有问题. CentOS yum之$releasever和$basearch分类: 操作系统 ...

  3. ”靠谱的C#“单例模式

    //静态构造函数的单例模式 public sealed class Singleton { private static readonly Singleton _instance = new Sing ...

  4. UITabBar 设置字体的颜色(选中状态/正常状态)setTitleTextAttributes

    UITabbar有个setTintColor这个方法,可以理解为,高亮的时候,或者点击后的颜色设置. UITabBarItem有个setTitleTextAttributes的方法,是用来设置字体的颜 ...

  5. CocoaPods的安装及使用/利用开源库Diplomat实现分享及第三方登录/git的使用

    <<史上最简洁版本>> 1.gem sources -l查看 当前的源 //1.1 sudo -i..以下都是以管理员的身份来操作的 2.gem sources --remov ...

  6. 【转】Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用

    Android M新控件之FloatingActionButton,TextInputLayout,Snackbar,TabLayout的使用 分类: Android UI2015-06-15 16: ...

  7. C#资源释放

    转自:http://www.cnblogs.com/psunny/archive/2009/07/07/1518812.html 深刻理解C#中资源释放 今天我的一个朋友看到我写的那篇<C#中用 ...

  8. saltstack之(十)扩展组件salt-ssh

    场景:公司有50台服务器,需要安装salt-minion客户端,并完成与salt-master的认证,接受salt-master的管理.本片文章只用了2台服务器做演示,大家可以在roster文件中定义 ...

  9. 浅析 Linux 初始化 init 系统,第 1 部分: sysvinit 第 2 部分: UpStart 第 3 部分: Systemd

    浅析 Linux 初始化 init 系统,第 1 部分: sysvinit  第 2 部分: UpStart 第 3 部分: Systemd http://www.ibm.com/developerw ...

  10. android mContainer.setPersistentDrawingCache (int drawingCacheToKeep)

    mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE); persistentDrawingCache设置 ...