如果再次按下按钮,我想保持对话框打开,但是当我按下它时,对话关闭。请帮助我如何保持开放的对话
public class MainActivity extends Activity implements OnClickListener{
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
final Builder ad = new AlertDialog.Builder(this);
ad.setCancelable(false);
ad.setNegativeButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int arg1) {
}
});
ad.setPositiveButton("Speak Again", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,int arg1) {
}});
ad.show();
}