这是我的警报代码,按下按钮时会显示一条消息。如何使 OK 按钮关闭?
Button bm1 = (Button) findViewById(R.id.button1);
bm1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog alert = new AlertDialog.Builder(screen4.this).create();
alert.setTitle("Doctor");
alert.setMessage("message");
alert.setCancelMessage(null);
alert.show();
}
});
}}
我已经放alert.setCancelMessage(null)
了,但它没有显示任何关闭按钮。
解决方案:
Button bm1 = (Button) findViewById(R.id.button1);
bm1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Builder alert = new AlertDialog.Builder(screen4.this);
alert.setTitle("Doctor");
alert.setMessage("message");
alert.setPositiveButton("OK", null);
alert.show();
}
});