Q:

Check if edittext is empty or not on custom dialog

I have taken a custom dialog with edittext on it to enter OTP. I have check whether OTP entered is correct or not. I also want to show toast message if no OTP is entered in edittext but the dialog opened should remain opened. Below is my code

alertDialogBuilder
    .setCancelable(false)
    .setPositiveButton("Ok",
    new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
    enterOtp=edtEnterOtp.getText().toString().trim();

    if(enterOtp.equals(randomNumber+"")){
    sendWalletBallance();
    }else{
    Toast.makeText(MerchantPayment.this,"OTP Mismatch",Toast.LENGTH_LONG).show();
    }
    }
    })
    .setNegativeButton("Cancel",
    new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
    dialog.cancel();
    }
    });

    AlertDialog alertDialog=alertDialogBuilder.create();

    alertDialog.show();

A:

if(enterOtp.equals(randomNumber+"")){
    sendWalletBallance();
    }else if(enterOtp.equals("")){
    Toast.makeText(MerchantPayment.this,"no otp is entered ",Toast.LENGTH_LONG).show();
    }else{
    Toast.makeText(MerchantPayment.this,"OTP Mismatch",Toast.LENGTH_LONG).show();
    }

You wanted to show A Toast then it ll help!!!

