Android 列表对话框 setItems
程序员文章站
2022-04-21 16:38:08
private Button button; private final CharSequence[] items = { "北京", "上海", "广州" }; @Override protected void onCreate(Bundle savedInstanceState) { super... ......
private button button; private final charsequence[] items = { "北京", "上海", "广州" }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button = (button) findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub alertdialog.builder builder = new alertdialog.builder(mainactivity.this); builder.settitle("请选择以下城市"); // builder.setmessage("请选择以下城市"); // 使用setmessage会覆盖setitems内容 builder.setitems(items, new onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { // todo auto-generated method stub charsequence sequence = items[which]; toast.maketext(mainactivity.this, "select " + sequence, 1).show(); } }); alertdialog dialog = builder.create(); dialog.show(); } }); }
推荐阅读
-
Android AlertDialog(对话框)实例详解
-
Android中创建一个透明的进度对话框实例
-
Android开发之PopupWindow创建弹窗、对话框的方法详解
-
Android 对话框dialog使用注意点(android.view.WindowManager$BadTokenException)
-
Android实现单选与多选对话框的代码
-
Android组件ListView列表简单使用
-
详解Android中提示对话框(ProgressDialog和DatePickerDialog和TimePickerDialog&PopupWindow)
-
实例详解Android自定义ProgressDialog进度条对话框的实现
-
Android 自定义ProgressDialog进度条对话框用法详解
-
Android仿QQ好友列表分组实现增删改及持久化