java - Custom AlertDialog disappears on back button press -
hi guys have custom alert dialog created. in builder set cancelable false yet still disappears when press button, ideas?
this code dialog:
public final class hemispheredialogfragment extends dialogfragment { @override public dialog oncreatedialog(bundle savedinstancestate) { // use builder class convenient dialog construction alertdialog.builder builder = new alertdialog.builder(getactivity()); layoutinflater inflater = getactivity().getlayoutinflater(); view customtitle = inflater.inflate(r.layout.hemisphere_dialog_custom_title, null); builder.setcustomtitle(customtitle); string[] entries = new string[2]; entries[0] = getresources().getstring(r.string.northern_hemisphere); entries[1] = getresources().getstring(r.string.southern_hemisphere); builder.setitems(entries, new dialoginterface.onclicklistener() { //the 'which' argument contains index position of selected item public void onclick(dialoginterface dialog, int which) { if( == 0 ) { globalvariables.getshared().setisinnorthernhemisphere(true); } else if( == 1 ) { globalvariables.getshared().setisinnorthernhemisphere(false); } toolbaractivity.outfitsfragment.hemisphereselected(); globalvariables.getshared().sethasaskedforhemisphere(true); } }); builder.setcancelable(false); //create alertdialog object , return return builder.create(); }
and how it's displayed:
new hemispheredialogfragment().show(getsupportfragmentmanager(), "hemispheredialog");
another small side question, there way change text size items in dialog?
you set alert dialog cancelable false, fragment still set cancelable, need add setcancelable(false)
fragment well.
Comments
Post a Comment