码迷,mamicode.com
首页 > 其他好文 > 详细

AlertDialog的写法

时间:2014-11-26 20:30:49      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   on   

 1 public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
 2         AlertDialog.Builder builder = new AlertDialog.Builder(this);
 3         builder.setTitle("选项");
 4         builder.setItems(R.array.choice, new DialogInterface.OnClickListener() {
 5             @Override
 6             public void onClick(DialogInterface dialog, int which) {
 7                 switch(which) {
 8                 case 0:
 9                     break;
10                 case 1:
11                     break;
12                 case 2:
13                     break;
14                 }
15                 
16             }
17         });
18         builder.setNegativeButton("取消", null);
19         builder.create().show();
20         
21     }

 

 

string.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <resources>
 3 
 4     <string name="app_name">AppExplorer</string>
 5     <string name="hello_world">Hello world!</string>
 6     <array name ="choice">
 7         <item name="start">启动程序</item>
 8         <item name="detail">详细信息</item>
 9         <item name="uninstall">卸载</item>
10     </array>
11 </resources>

效果:

bubuko.com,布布扣

AlertDialog的写法

标签:style   blog   http   io   ar   color   os   sp   on   

原文地址:http://www.cnblogs.com/hixin/p/4124040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!