asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
package com.asfman;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class SelectMenu extends Activity {
    
/** Called when the activity is first created. */
    @Override
    
public void onCreate(Bundle savedInstanceState) {
        
super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button oButton 
= (Button) findViewById(R.id.button1);
        oButton.setOnClickListener(
new Button.OnClickListener() {

            @Override
            
public void onClick(View v) {
                
// TODO Auto-generated method stub
                new AlertDialog.Builder(SelectMenu.this)
                .setTitle(
"按我开始选择")
                .setItems(R.array.items,  
new DialogInterface.OnClickListener() {
                    
                    @Override
                    
public void onClick(DialogInterface dialog, int which) {
                        
// TODO Auto-generated method stub
                        final String[] arrStrings = getResources().getStringArray(R.array.items);
                        
final AlertDialog oAlertDialog = new AlertDialog.Builder(SelectMenu.this)
                        .setTitle(
"which:" + arrStrings[which])
                        .show();
                        
new Thread() {
                            @Override
                            
public void run() {
                                
// TODO Auto-generated method stub
                                try {
                                    sleep(
3000);
                                }
 catch (Exception e) {
                                    
// TODO: handle exception
                                }
 finally {
                                    oAlertDialog.dismiss();
                                }

                            }

                        }
.start();
                    }

                }
).show();
            }

            
        }
);
    }

}

strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    
<string name="hello">Hello World, SelectMenu!</string>
    
<string name="app_name">SelectMenu</string>
    
<string name="btnTxt">按我啊</string>
    
<array name="items">
        
<item>中国</item>
        
<item>利比亚</item>
        
<item>朝鲜</item>
    
</array>
</resources>
posted on 2011-03-29 17:16 汪杰 阅读(155) 评论(0)  编辑 收藏 引用 所属分类: Java
只有注册用户登录后才能发表评论。

<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 456697
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜