Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'+"");` 
like image 817
9patchcoder Avatar asked Jul 09 '14 20:07

9patchcoder


People also ask

What does backspace character mean?

Definitions of backspace character. a control character that indicates moving a space to the left. type of: ASCII control character, control character. ASCII characters to indicate carriage return or tab or backspace; typed by depressing a key and the control key at the same time.

How do you add a backspace symbol in HTML?

␈ - symbol for backspace (U+2408) - HTML Symbols.


2 Answers

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.

like image 50
Jon Skeet Avatar answered Sep 24 '22 16:09

Jon Skeet


Seems like the default Android font (Roboto / droid sans serif) doesn't include this character, so it can't display it (I still haven't figured out how the preview shows it). So you need to find a font that supports this character. The best candidate I've found is Arial Unicode MS, but these work too:

  • Quivira (free)
  • Symbola
  • Segoe UI (windows phone's)
  • DejaVu sans (free)
  • Apple Symbols
like image 38
9patchcoder Avatar answered Sep 22 '22 16:09

9patchcoder