如果您可以幫助我解決這個問題,我有一個單選警報對話框有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;
您的幫助非常感謝。 謝謝
WHU你不能創造我們的定製dialog.so你可以輕鬆地處理所有這些事情 – dipali
你可以用這一個經歷,因爲這個環節也解決了礦山的同樣的問題。它根據需要顯示帶三個按鈕的警報對話框。 http://www.learn2crack.com/2013/11/android-alertdialog-example.html – Poison