Android 列表对话框 使用数组
2024-10-05 03:11:20
添加一个数组
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
// TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("请选择以下城市"); builder.setMultiChoiceItems(R.array.city, new boolean[] { false, false, false },
new OnMultiChoiceClickListener() { @Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
// TODO Auto-generated method stub }
}); AlertDialog dialog = builder.create();
dialog.show();
}
});
}
<?xml version="1.0" encoding="utf-8"?>
<resources> <string name="app_name">Android_multiDialog_test</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string> <string-array name="city">
<item>北京</item>
<item>上海</item>
<item>广州</item>
</string-array> </resources>
最新文章
- WCF Misconfiguration: Insufficient Audit Failure Handling
- <;转>;linux crontab 定时任务
- 怎样写 OpenStack Neutron 的 Plugin (二)
- Android:ScaleType设置图片
- IMS 相关名词解释
- Linux从零到高手的进阶心得(转)
- iOS开发的一些奇巧淫技2
- Bootstrap 模态框
- Office2016 KMS激活
- swift 实现拍照 选择相册
- bzoj5102: [POI2018]Prawnicy
- [转]关于ios 推送功能的终极解决
- 初识 数据库及Oracle数据库
- [codeforces][Educational Codeforces Round 53 (Rated for Div. 2)D. Berland Fair]
- (笔记)ubuntu中取消文件夹或文件等右下解一把锁的标志的方法
- C# 序列化(Serialize)与反序列化(Deserialize)
- python下爬某个网页的图片
- NSLayout​Constraint
- 适用于iOS6之后的苹果提供的下拉刷新
- .net 特性 Attribute