令狐冲浪的博客

My Life, My Blog~~

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  4 Posts :: 0 Stories :: 0 Comments :: 0 Trackbacks

2010年12月15日 #

 1package com.pptv.lesson05;
 2
 3import android.app.Activity;
 4import android.app.AlertDialog;
 5import android.content.DialogInterface;
 6import android.os.Bundle;
 7import android.view.View;
 8import android.widget.Button;
 9
10public class lesson05Acitivity extends Activity {
11    /** Called when the activity is first created. */
12    @Override
13    public void onCreate(Bundle savedInstanceState) {
14        super.onCreate(savedInstanceState);
15        setContentView(R.layout.main);
16        Button button = (Button)findViewById(R.id.button_ok);
17        button.setOnClickListener(new View.OnClickListener() {
18            
19            @Override
20            public void onClick(View v) {
21                // TODO Auto-generated method stub
22                new AlertDialog.Builder(lesson05Acitivity.this)
23                .setTitle("警告:").setMessage("你点击了按钮!").setPositiveButton("关 闭"new DialogInterface.OnClickListener() {
24                    
25                    @Override
26                    public void onClick(DialogInterface dialog, int which) {
27                        // TODO Auto-generated method stub
28                        finish();
29                    }

30                }
)
31                    .show();
32                
33            }

34        }
);
35    }

36}
posted @ 2010-12-15 18:01 令狐冲浪 阅读(172) | 评论 (0)编辑 收藏