我在alertdialog中有三个复选框。我希望当我点击sencond复选框时,它会一直检查,直到用户不按照他/她的说服点击其他复选框。这是我的代码请提供一些sugestions。
编辑:意味着即使用户关闭了应用程序,也只会点击一个复选框。
我的代码:
case SYNC_ALERT:
AlertDialog.Builder alertbuilder = new AlertDialog.Builder(this);
alertbuilder.setMessage("Synchronization");
alertbuilder.setCancelable(false);
LayoutInflater buildinflater = this.getLayoutInflater();
View SyncView= buildinflater.inflate(R.layout.sync_layout, null);
alertbuilder.setView(SyncView);
defaultchkbox = (CheckBox)SyncView.findViewById(R.id.defaultchkbox);
after15mint = (CheckBox)SyncView.findViewById(R.id.after15mint);
afternmint = (CheckBox)SyncView.findViewById(R.id.afternmint);
alarms = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alertbuilder.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
//Implement search method here
if(defaultchkbox.isChecked())
{
//some code here
}
else if(after15mint.isChecked())
{
//some code here
}
else
{
//Some code here
}
}
});
alertbuilder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
});
AlertDialog alertdialog = alertbuilder.create();
alertdialog.show();