package com.moon.hello2;import java.util.ArrayList;import java.util.Calendar;import java.util.HashMap;import java.util.List;import java.util.Map;import android.R.anim;import android.R.integer;import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.content.res.TypedArray;import android.database.DataSetObserver;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.Gravity;import android.view.Menu;import android.view.View;import android.view.ViewGroup;import android.view.View.OnClickListener;import android.view.ViewGroup.LayoutParams;import android.view.animation.AnimationUtils;import android.widget.AbsListView;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.AdapterView.OnItemSelectedListener;import android.widget.ArrayAdapter;import android.widget.AutoCompleteTextView;import android.widget.BaseAdapter;import android.widget.Button;import android.widget.DatePicker;import android.widget.ExpandableListAdapter;import android.widget.ExpandableListView;import android.widget.Gallery;import android.widget.GridView;import android.widget.ImageSwitcher;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.ListView;import android.widget.ProgressBar;import android.widget.RatingBar;import android.widget.SimpleAdapter;import android.widget.RatingBar.OnRatingBarChangeListener;import android.widget.SeekBar;import android.widget.DatePicker.OnDateChangedListener;import android.widget.SeekBar.OnSeekBarChangeListener;import android.widget.TabHost;import android.widget.TextView;import android.widget.TimePicker;import android.widget.TimePicker.OnTimeChangedListener;import android.widget.ViewSwitcher.ViewFactory;public class MainActivity extends Activity { private final int[] imgs = new int[] { R.drawable.a1, R.drawable.a2, R.drawable.a3, R.drawable.a4, R.drawable.a5, R.drawable.a6, R.drawable.a7, R.drawable.a8 }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); Button button = (Button)findViewById(R.id.button1); final TextView textView = (TextView)findViewById(R.id.textView1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setMessage("这是一个用于测试的dialog"); builder.setIcon(R.drawable.ic_launcher); builder.setTitle("这是title"); builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub textView.setText("你按下了确认键"); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { // TODO Auto-generated method stub textView.setText("你按下了取消键"); } }); builder.create().show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; }}