Android : Button dependency on checkbox in Alert dialog -


i've activity starts alert dialog prompt. have checkbox of don't show again. want button clickable after checkbox clicked, thnx in advance, hope words make understand looking for. here's code:

    @override     protected void onresume() {         alertdialog.builder adb = new     alertdialog.builder(this);         layoutinflater adbinflater =     layoutinflater.from(this);         view eulalayout = adbinflater.inflate(r.layout.note_for_layout, null);     final checkbox dontshowagain = (checkbox) eulalayout.findviewbyid(r.id.skip);          adb.setcancelable(false);          adb.setview(eulalayout);         adb.settitle("warning!");          adb.setmessage("");   adb.seticon(r.drawable.alert1);     adb.setpositivebutton("accept",     new dialoginterface.onclicklistener() {                 public void     onclick(dialoginterface dialog, int which) {                    string checkboxresult =     "not checked";                     if (dontshowagain.    ischecked())                         checkboxresult =     "checked";                     string     prefs_name = null;                         sharedpreferences settings = getsharedpreferences(prefs_name, 0);                         sharedpreferences.editor editor = settings.edit();                     editor.putstring("skipmessage", checkboxresult);                  editor.commit();                      return;             }         });           adb.setnegativebutton("decline", new dialoginterface.onclicklistener() {             public void     onclick(dialoginterface dialog, int which) {                 string checkboxresult = "not checked";                 if (dontshowagain.ischecked())                     checkboxresult = "checked";                     string prefs_name = null;                     sharedpreferences settings = getsharedpreferences(prefs_name, 0);                         sharedpreferences.editor editor = settings.edit();                 editor.putstring("skipmessage", checkboxresult);                 // commit edits!                 editor.commit();                     finish();             }         });         string prefs_name = null;         sharedpreferences settings = getsharedpreferences(prefs_name, 0);         string skipmessage = settings.getstring("skipmessage", "not checked");     if (!skipmessage.equals("checked"))         adb.show();          super.onresume(); 

you can enable or disable button using code.

dialog.getbutton(dialoginterface.button_positive).setenabled(true/false); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -