简体   繁体   中英

How do you do a backspace escape character in Android?

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

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

But instead of the \\b doing a backspace, they show up as little squares in the textfield. Can anyone help me out here?

You should be able to achieve the same effect by grabbing all the text except the last 4 characters and then appending your new text.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM