[英]How do you do a backspace escape character in Android?
I have a textView with some text in it. 我有一个textView,里面有一些文字。 I want to delete the last 4 characters and then add on some more text.
我想删除最后4个字符,然后再添加一些文字。 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. 但是,不是\\ b做退格,它们在文本字段中显示为小方块。 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. 您应该能够通过抓取除最后4个字符之外的所有文本然后附加新文本来达到相同的效果。
String textViewText = textViewObject.getText().toString();
textViewObject.setText(textViewText.substring(0, textViewText.getLength() - 4) +
" new text that I am adding");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.