How to make a button that shows the backspace (⌫) character on Android?

9patchcoder picture 9patchcoder · Jul 9, 2014 · Viewed 20k times · Source

I'm trying to use the ⌫ character as my backspace symbol in my android app. When I just copy and paste this character as the text value of my Button it works and shows the symbol in the simulator, but when I try to set this character dynamically in Java or when I try to use the Basic Latin value of it (\u232b) it just shows whitespace.

This is when I use the XML editor and my strings.xml value:

enter image description here

My strings.xml:

<?xml version="1.0" encoding="utf-8"?>
  <resources>
      <string name="backSpace">⌫</string>
  </resources>   

In Java I tried hardcoding it like this, but they all result in whitespace:

((Button) mView.findViewById(R.id.buttonClear)).setText("⌫");   
((Button) mView.findViewById(R.id.buttonClear)).setText("\u232b");` 
((Button) mView.findViewById(R.id.buttonClear)).setText('\u232b'+"");` 

Answer

Jon Skeet picture Jon Skeet · Jul 9, 2014

That character is not U+0008. U+0008 is a control character, without a graphical representation.

⌫ is U+232B (the "erase to the left" symbol), so if you use "\u232b" in your app it should be fine.