Skip to content Skip to sidebar Skip to footer

Dialog Still Show After Click Positive Button

I have button on (CustomDilaog activity) when clicked show custom dialog with password edittext and OK button and cancel button , if you put correct password it open another activi

Solution 1:

call dialog.dismiss() at the beginning of dialogButton click listener:

dialogButton.setOnClickListener(newOnClickListener() {
   publicvoidonClick(View v) {

      dialog.dismiss();

      EditTextpassword= (EditText) dialog.findViewById(R.id.password);
      if( password.getText().toString().length() > 0 ) {

      ...
   }
});

Solution 2:

Part one : when im in (Text activity) and press back button to return to (CustomDilaog activity) , still the dialog show over it , how to let it dismiss

Simply call finish() in your CustomDialogActivity when you start the new Activity. It looks like your Intent is calling this same Activity though so I'm a little confused on that.

if( password.getText().toString().length() > 0 ) {
       if( password.getText().toString().equals("test")) {
            Intent intent = new Intent(CustomDilaog.this,Text.class);
            startActivity(intent);

Part two : after dialog fired , if i dont write password and just click OK button with edittext empty it has no response , how to let this click just dismiss dialog without no action ( which is open (Text activity) if wrote correct password .

Add an else statement to your first if and inside it put dialog.dismiss()

Post a Comment for "Dialog Still Show After Click Positive Button"