如果您能帮我,我有一个包含3个选项的单选弹出框。开始时,我禁用了NEXT按钮(没有选择任何选项)。当用户选择任何选项时,我想启用NEXT按钮。这是我尝试的代码。
int involvementInIncident;
case DIALOG_ADD_A_PERSON_INVOLVEMENT_ONE:
builder.setTitle("Involvement in this Incident");
builder.setSingleChoiceItems(incidentInvolvement, -1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
involvementInIncident = which;
//involvementInIncident = ((AlertDialog)dialog).getListView().getCheckedItemPosition();
Toast.makeText(getApplicationContext(),""+ involvementInIncident, Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("Next",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Toast.makeText(getApplicationContext(),""+ involvementInIncident, Toast.LENGTH_SHORT).show();
showDialog(DIALOG_ADD_A_PERSON_PERSON_TYPE_TWO);
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alertInvolvement = builder.create();
alertInvolvement.show();
final Button buttonPositiveInvolvement = alertInvolvement.getButton(AlertDialog.BUTTON_POSITIVE);
buttonPositiveInvolvement.setEnabled(false);
if(involvementInIncident == 0 || involvementInIncident == 1 || involvementInIncident==2){
buttonPositiveInvolvement.setEnabled(true);
//Toast.makeText(getApplicationContext(),"person responsiblee", Toast.LENGTH_SHORT).show();
}
else
{
buttonPositiveInvolvement.setEnabled(false);
}
return dialog;
非常感谢您的帮助。
谢谢。