android 的AlertDialog对话框
private int selectedFruitIndex = 0;
private void showMsg2()
{
// Dialog alertDialog = new AlertDialog.Builder(this).
// setTitle("确定删除?").
// setMessage("您确定删除该条信息吗?").
// setIcon(R.drawable.ic_launcher).
// setPositiveButton("确定", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// // TODO Auto-generated method stub
// }
// }).
// setNegativeButton("取消", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// // TODO Auto-generated method stub
// }
// }).
// setNeutralButton("查看详情", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// // TODO Auto-generated method stub
// }
// }).
// create();
// alertDialog.show();
// final String[] arrayFruit = new String[] { "苹果", "橘子", "草莓", "香蕉" };
//
// Dialog alertDialog = new AlertDialog.Builder(this).
// setTitle("你喜欢吃哪种水果?").
// setIcon(R.drawable.ic_launcher)
// .setItems(arrayFruit, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// Toast.makeText(PubMainActivity.this, arrayFruit[which], Toast.LENGTH_SHORT).show();
// }
// }).
// setNegativeButton("取消", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// // TODO Auto-generated method stub
// }
// }).
// create();
// alertDialog.show();
// final String[] arrayFruit = new String[] { "苹果", "橘子", "草莓", "香蕉" };
//
// Dialog alertDialog = new AlertDialog.Builder(this).
// setTitle("你喜欢吃哪种水果?").
// setIcon(R.drawable.ic_launcher)
// .setSingleChoiceItems(arrayFruit, 0, new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// selectedFruitIndex = which;
// }
// }).
// setPositiveButton("确认", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// Toast.makeText(PubMainActivity.this, arrayFruit[selectedFruitIndex], Toast.LENGTH_SHORT).show();
// }
// }).
// setNegativeButton("取消", new DialogInterface.OnClickListener() {
//
// @Override
// public void onClick(DialogInterface dialog, int which) {
// // TODO Auto-generated method stub
// }
// }).
// create();
// alertDialog.show();
final String[] arrayFruit = new String[] { "苹果", "橘子", "草莓", "香蕉" };
final boolean[] arrayFruitSelected = new boolean[] {true, true, false, false};
//
// LayoutInflater factory = LayoutInflater.from(PubMainActivity.this);
// //获得自定义对话框
// View view = factory.inflate(R.layout.item_listitem, null);
Dialog alertDialog = new AlertDialog.Builder(this).
setTitle("你喜欢吃哪种水果?").
setIcon(R.drawable.ic_launcher)
.setMultiChoiceItems(arrayFruit, arrayFruitSelected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
arrayFruitSelected[which] = isChecked;
}
}).
setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < arrayFruitSelected.length; i++) {
if (arrayFruitSelected[i] == true)
{
stringBuilder.append(arrayFruit[i] + "、");
}
}
Toast.makeText(PubMainActivity.this, stringBuilder.toString(), Toast.LENGTH_SHORT).show();
}
}).
setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).
create();
alertDialog.show();
}
android 的AlertDialog对话框的更多相关文章
- Android:AlertDialog对话框
1.简单的ALertDialog: Dialog alertDialog = new AlertDialog.Builder(this) .setTitle("标题") .setM ...
- 【Android】Android中AlertDialog对话框的使用实例
package com.ceac.deng; import android.R.string; import android.support.v7.app.ActionBarActivity; imp ...
- Android在 Alertdialog对话框中点击消失?
在开发的时候遇到一个问题.就是一触摸对话框边缘外部,对话框会自己主动消失.这个问题非常纠结啊,查找了一下发现从Android 4.0開始.AlertDialog有了变化.就是在触摸对话框边缘外部.对话 ...
- android入门 — AlertDialog对话框
常见的对话框主要分为消息提示对话框.确认对话框.列表对话框.单选对话框.多选对话框和自定义对话框. 对话框可以阻碍当前的UI线程,常用于退出确认等方面. 在这里主要的步骤可以总结为: 1.创建Aler ...
- Android中AlertDialog对话框禁止按[返回键]或[搜索键]
alertDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(Di ...
- 11.Android之常用对话框AlertDialog学习
(1)首先我们写个简单的AlertDialog对话框,要创建一个AlertDialog,就要用到AlertDialog.Builder中的create()方法,然后创建对话框可以设置对话框的属性,比如 ...
- android中常见对话框之一AlertDialog
在Android应用中,有多种对话框:Dialog.AlertDialog.ProgressDialog.时间.日期等对话框. (1)Dialog类,是一切对话框的基类,需要注意的是,Dialog类虽 ...
- Android应用开发学习之AlertDialog对话框
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 本文中我们通过一个例子来看AlertDialog对话框的实现,其运行效果如下: 主布局文件main.xml内容如下: ...
- Android中弹出对话框,AlertDialog关键代码
写在这里便于以后查看. Android中弹出对话框的关键代码: btn01.setOnClickListener(new OnClickListener() { @Override public vo ...
随机推荐
- hdu 3613 Best Reward
After an uphill battle, General Li won a great victory. Now the head of state decide to reward him w ...
- 【java基础】java关键字final
谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关键字.另外,Java中的String类就是一个final类,那么今天我们就来了解final这个关键字的用法.下 ...
- 【java基础】ThreadLocal的实现原理
[一]:ThreadLocal对象的大体实现原理===>当前线程对象有一个ThreadLocal.ThreadLocalMap属性.===>声明的ThreadLocal对象最终存储在当前线 ...
- Jenkins在windows环境下安装无法安装插件
在windos平台下安装jenkins要是无法安装插件,tomcat控制台报以下错误: 解决方法: 进入到jenkins里头,Jenkins -- 管理插件 -- 高级 -- 升级站点,如图所示: 将 ...
- bzoj4576 [Usaco2016 Open]262144
题目大意: 给出n个数a[1..n],n<=262144,a[i]<=40,相邻且相同的数可以合并成一个并将值加1,问能获得的最大数是多少 用一个双向链表维护原数列,每个节点记录此节点对应 ...
- rpc简易实现-zookeeper
一.RPC(Remote Procedure Call)—远程过程调用,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.RPC协议假定某些传输协议的存在,如TCP或UDP, ...
- hadoop2.6.0的eclipse插件编译和设置
编译hadoop2.6.0的eclipse插件 下载源码: git clone https://github.com/winghc/hadoop2x-eclipse-plugin.git 编译源码: ...
- cmd,amd,umd 模块写法
mark一篇感觉写的不错的cmd/amd/umd的模块写法 原文:https://github.com/banricho/webLog/issues/12 umd通用写法: // jQuery 2.2 ...
- [Python] numpy.Matrix
import numpy as np np.matrix('1, 2; 3, 4') #1, 2 #3, 4 np.matrix([[1,2],[3,4]]) #1, 2 #3, 4
- python爬虫 发送定时气象预报
python爬取天气情况 下面为示例代码: from urllib.request import urlopen from bs4 import BeautifulSoup from urllib.e ...