Sunday 15 July 2012

android - Cancel the dismiss of a DialogFragment after PositiveButton clicked -


I have added a DialogFragment I only have one EditText And accept and cancel button.

Inside this, a text is entered in EditText ; So, when clicking on accept, the text is checked using the try / catch .

Try inside , if everything goes well, then I reject the dialogue; If the flow enters hold , then this idea is to maintain the dialogue and not to dismiss it, so that the user can get an opportunity to correct the text.

  @Override public dialog on crude digital (bundle saved instenstate) {... builder.setPositiveButton (android.R.string.ok, New OnClickListener) {Click Public Zero ( DialogInterface dialogue, int id) {onAcceptDialog ();}}) ...}. .. acceptance on private zeros () (try {... this.dismiss ();} hold (exception e) {... // dialog is still being rejected, though it should not be}}   

However, the dialog is still being dismissed, though I can this.dismiss () inside hold .

There is no way to cancel the dismissal inside onAcceptDialog () ?

I have found a custom dialog to resolve this problem. @ Override Protected Dialogue on Create Dialogue (Int ID) {Final AlertDialog.Bloulder Warning = New AlertDialog Builder (this); alert.setTitle ("Test"); alert.setIcon (R.drawable.logo1) ; Alert.setMessage ("Customer service is dedicated to company." LinearLayout Leila 1 = new linerlayout (this); linear line linbuttons = new linear line (this); linbuttons.setOrientation (LinearLayout.HORIZONTAL); button btnPositive = new button ); Button btnNegative = New button (this); btnPositive.setText ("Send"); Write your code to send to BtnPositive.setOnClickListener (New OnClickListener () {@Override Public Zero (see V) {//) BckPressed ();}}); BtnNegative.setText ("Cancel"); Click on BtnNegative.setOnClickListener (New OnClickListener) {@Override Public Zero (see V) {onBackpressed ();}}); Linbuttons.addView (btnPositive); Linbuttons.addView (btnNegative); Lila1.addView (linbuttons); Return warning. Create (); }}

Hope for you that this will help you.

No comments:

Post a Comment