Android EditText - Delete the last letter with a button

后端 未结 4 1996
我寻月下人不归
我寻月下人不归 2021-01-13 16:29

I have to buttons that writes A and B to an edittext. If there is something in the edittext how can I delete the last letters with the \"Del\" button? My layout:

<         


        
4条回答
  •  半阙折子戏
    2021-01-13 17:09

    String text = editText.getText().toString();
    if(text.length() > 0){
      text = str.substring(0, str.length()-1);
       editText.setText(text);
    }
    

提交回复
热议问题