Android单选、多选列表的对话框
来源:互联网 发布:linux下查看文件大小 编辑:程序博客网 时间:2024/06/08 02:33
1、创建带单选项列表的对话框
下面代码将打开一个选项列表对话框:
final String[] items = {"java", ".net", "php"}; new AlertDialog.Builder(SenderNotificationActivity.this).setTitle("选择语言") .setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); } }).show();//显示对话框
下面代码将打开一个带单选框的列表对话框:
final String[] items = {"java", ".net", "php"}; new AlertDialog.Builder(SenderNotificationActivity.this).setTitle("选择语言") .setSingleChoiceItems(items, 1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); dialog.cancel(); } }).show();//显示对话框
setSingleChoiceItems()的第二个参数是设置默认选项,
选项索引从0开始,-1代表不选择任何选项。
2、创建带多选项列表的对话框
下面代码将打开一个多选项列表对话框:
final String[] items = {"java", ".net", "php"}; new AlertDialog.Builder(SenderNotificationActivity.this).setCancelable(false) .setTitle("选择语言") .setMultiChoiceItems(items, new boolean[]{false,true,false}, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if(isChecked){ Toast.makeText(getApplicationContext(), items[which], Toast.LENGTH_SHORT).show(); } } }) .setPositiveButton("确认", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialoginterface, int i){ dialoginterface.dismiss(); } }) .show();//显示对话框
- Android单选、多选列表的对话框
- Android-Dialog对话框 全解(普通对话框,单选对话框,多选对话框,列表对话框,自定义对话框,Activity对话框)
- 显示选择省份的三种列表对话框-列表对话框,单选列表对话框,多选列表对话框
- Android简单对话框、输入对话框、单选对话框、复选对话框、列表对话框、自定义对话框、时间对话框
- AlertDialog创建6种对话框的用法 (对话框,单选对话框,多选对话框,列表对话框,自定义对话框,退出对话框)
- Android单选列表对话框builder.setSingleChoiceItems
- android中列表选项、单选选项、多选选项对话框的使用
- Android使用AlertDialog的信息列表单选、多选对话框
- 安卓通知的使用系列4:对话框通知的使用之列表对话框、单选列表对话框、多选列表对话框
- Android的普通对话框,单选和多选对话框
- 17. android dialog —— 单选列表对话框
- android 显示单选列表对话框 builder.setSingleChoiceItems
- android 显示单选列表对话框 builder.setSingleChoiceItems
- android 显示单选列表对话框 builder.setSingleChoiceItems
- android 展示单选列表对话框 builder.setSingleChoiceItems
- android通知对话框、多选对话框、单选对话框
- android 单选对话框
- 使用AlertDialog创建单选列表对话框
- python二分法排序
- Oracle 11gR2 RAC TNS-12542: TNS:address already in use 故障一例
- 八、CCMenu和CCMenuItem
- wx记事本
- 159 samba 无法访问。您可能没有权限使用网络资源 net use命令
- Android单选、多选列表的对话框
- [Errno 13] Permission denied处理
- 什么是左连接、右连接和全连接、内连接?
- Ubuntu 10.04 Server下編譯libjingle-0.6.14
- php+nginx配置
- (unknown): x.x.x.x:2376 Status: Pending ID:
- 快速取模运算
- 'ascii' codec can't encode characters in position 34-41: ordinal not in range(128)处理
- Myeclipse 10 for Mac安装破解及其SVN插件安装