How do you execute escape character in Android?

I have a textView with some text in it. I want to delete the last 4 characters and then add more text. I tried to do it.

textViewObject.append("\b\b\b\b new text that I am adding");

But instead of \ b doing backspace, they appear as small squares in the text box. Can someone help me here?

+3
source share
1 answer

You should be able to achieve the same effect by capturing all text except the last 4 characters, and then adding new text.

String textViewText = textViewObject.getText().toString();
textViewObject.setText(textViewText.substring(0, textViewText.getLength() - 4) + 
                                                   " new text that I am adding");
+2
source

Source: https://habr.com/ru/post/1758246/


All Articles