vendredi 14 août 2020

Why button click showing error in if else condition?

When I click on buttondel, the code inside 'if-block' is working fine but when it goes inside 'else-block' it is showing error i.e. it is not showing toast.

buttondel.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (edittext!=null){
        String newtext = edittext.getText().toString();
        edittext.setText(newtext.substring(0, newtext.length() - 1));
        }
    else {
            Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT).show();
        }
    }

});

Aucun commentaire:

Enregistrer un commentaire