public class main extends Activity {
private Button AlertButton;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AlertButton = (Button) findViewById(R.id.AlertButton);
AlertButton.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View arg0) {
new AlertDialog.Builder(main.this).setTitle("AlertTest")
.setMessage("Alert Body").setPositiveButton("Exit"
,new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int which) {
//要做的事情.....
}
}).show();
}
});
}
沒有留言:
張貼留言