android 带CheckBox对话框
package com.example.dialog4;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends Activity {
final String[] Fruit = new String[] {"苹果", "橘子", "草莓", "香蕉"};
final boolean[] FruitsSelected = new boolean[] {true, true, false, false};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog myDialog= new AlertDialog.Builder(MainActivity.this)
.setTitle("标题")
.setIcon(R.drawable.ic_launcher)
.setMultiChoiceItems(Fruit, FruitsSelected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, Fruit[which]+(isChecked?"勾选":"取消"), Toast.LENGTH_SHORT).show();
}
})
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.create();
myDialog.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;
}
}
android 带CheckBox对话框的更多相关文章
- Android 带checkbox的listView 实现多选,全选,反选,删除
activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...
- Android 带checkbox的listView 实现多选,全选,反选
由于listview的一些特性,刚开始写这种需求的功能的时候都会碰到一些问题,重点就是存储每个checkbox的状态值,在这里分享出了完美解决方法: 布局文件: [html] <?x ...
- 【转】Android 带checkbox的listView 实现多选,全选,反选 -- 不错
原文网址:http://blog.csdn.net/onlyonecoder/article/details/8687811 Demo地址(0分资源):http://download.csdn.net ...
- 【转】Android 带checkbox的listView 实现多选,全选,反选----解决checkbox错位问题
原文网址:http://blog.csdn.net/onlyonecoder/article/details/8687811 Demo地址(0分资源):http://download.csdn.net ...
- android 带listview对话框
package com.example.dialog2; import android.os.Bundle;import android.app.Activity;import android.app ...
- android 带checkbox的List
可实现点击内容即可选中 http://blog.csdn.net/harvic880925/article/details/40475367
- Android:AlertDialog对话框
1.简单的ALertDialog: Dialog alertDialog = new AlertDialog.Builder(this) .setTitle("标题") .setM ...
- Android 自学之对话框
Android为我们提供了丰富的对话框支持,提供了四种常用的对话框: AlertDialog:功能丰富.实际应用最广泛的对话框. ProgressDialog:进度对话框,该对话框只用于简单的进度条封 ...
- 【转】带checkbox的ListView实现(二)——自定义Checkable控件的实现方法
原文网址:http://blog.csdn.net/harvic880925/article/details/40475367 前言:前一篇文章给大家展示了传统的Listview的写法,但有的时候我们 ...
随机推荐
- 【BZOJ】1647: [Usaco2007 Open]Fliptile 翻格子游戏(暴力)
http://www.lydsy.com/JudgeOnline/problem.php?id=1647 自己太弱...看题解.. 竟然是枚举第一行的放法,,,因为一定要全部变0,所以将前一行1的在这 ...
- c# http请求,获取非200时的响应体
HttpWebResponse res = null; try { res = request.GetResponse() as HttpWebResponse; } catch (WebExcept ...
- [转] 关于EJB分析
转自:http://blog.csdn.net/jojo52013145/article/details/5783677 1. 我们不禁要问.什么是"服务集群"?什么是" ...
- 系统管理模块_岗位管理_改进_使用ModelDroven方案_套用美工写好的页面效果_添加功能与修改功能使用同一个页面
改进_使用ModelDroven方案 @Controller @Scope("prototype") public class RoleAction extends ActionS ...
- OSG简单测试框架
#include <osgDB/ReadFile> #include <osgDB/FileUtils> #include <osg/ArgumentParser> ...
- ios常用第三方库git下载地址
本文转载至 http://blog.csdn.net/cerastes/article/details/38348599 iOS第三方库下载常用git 1.FMDB https://github.co ...
- mysql用sql创建表完整实例
create table user_login_latest( id int(11) unsigned NOT NULL AUTO_INCREMENT, user_id int(11) not nul ...
- vue-router scrollBehavior无效的问题
在使用vue做单页面应用开发时候 使用vue-router作为路由控制器 在使用过程中发现每个页面打开都在原来的位置 不能返回到页面顶部位置 ,然后查看api文档 滚动行为 发现如下代码: con ...
- 160418、ztree权限菜单
1.页面中引用ztree的css和js(大家自行下载ztree) <link rel="stylesheet" href="${ctx}/resources/js/ ...
- 面试之一:CMS收集器整理
CMS收集器整理 @white 基本说明: 目标:获取最短回收停顿时间 算法:标记-清除算法 线程:并发 步骤: 初始标记:(会STP) 标记 GC Roots 能直接关联到的对象,速度很快 并发 ...