22

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'+"");` 
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
9patchcoder
  • 619
  • 1
  • 5
  • 17
  • [This tool](http://rishida.net/tools/conversion/) might be helpful to find Unicode value of character or vice versa. – Keppil Jul 09 '14 at 20:10
  • And it *definitely* works when you use it in the resource file? That's very strange - it should be fine when hard-coded in that case. Silly question, but if you hard code it to something else, e.g. "A", does that work? – Jon Skeet Jul 09 '14 at 21:23
  • yes for Other letters like "A" it Works ... I think this one is not fully supported ... no wonder why Google hasn't used this Character in the Native Calculator app and just wrote "Delete"! – 9patchcoder Jul 09 '14 at 21:37

5 Answers5

23

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.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 1
    Yes the Latin Code was \u232B but it still doesn't print the character in java or xml ... it just shows white space when i run the app ? – 9patchcoder Jul 09 '14 at 20:29
  • @9patchcoder: What do you mean by "Latin Code"? And where are you putting the `\u232b`? (Note that I made a mistake in my previous version - if you'd put `\u023b`, try again with `\u232b`. Just a typo.) – Jon Skeet Jul 09 '14 at 20:42
  • Base Latin format as in \u232b yeah I just noticed it and was like what ? :D I pasted some code ... can't put the screenshot directly becuz of being noob aparently – 9patchcoder Jul 09 '14 at 21:20
  • 1
    @9patchcoder: I've never heard that called "base Latin format" before. It's a Java Unicode escape sequence... – Jon Skeet Jul 09 '14 at 21:22
  • Me neither ! but that's what android studio calls it http://cld.persiangig.com/preview/ChS4YCoj9k/Basic%20Latin.png – 9patchcoder Jul 09 '14 at 21:26
  • @9patchcoder: I think that's just saying that the characters in the source code will be ASCII Latin characters. It's not a technical term. – Jon Skeet Jul 09 '14 at 21:35
  • Is there an inverted version of that character (white X and black arrow)? – Jon Kantner Nov 05 '15 at 21:52
  • @GhostCoder20: Not that I'm aware of. – Jon Skeet Nov 06 '15 at 06:43
  • @9patchcoder was right, I have the same problem using old Android APIs like 15 or 16 – boctulus Dec 19 '17 at 22:03
5

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
Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
9patchcoder
  • 619
  • 1
  • 5
  • 17
4

My approach is to use an ImageButton together with standard platform Drawables. You can actually see the standard Drawables available for various platforms by browsing your Android SDK directory: Sdk/platforms/android-XXX/data/res/

This gives you a button with the backspace symbol:

    <ImageButton
        android:src="@drawable/sym_keyboard_return"
        ...
    />

Note: Google actually advise against referencing Android resources directly and advise making a local copy (see here). Therefore, try the above to see what the icon looks like (or have a browse inside the SDK folders mentioned above to see all the .png drawables directly), but for production it is best to copy the .png images for each desired resolution to your own project and reference those.

For what it's worth, there are various other very useful symbol images, such as a 'return' symbol (sym_keyboard_return.png, for example). Many of them such as sym_keyboard_return aren't referenced in android.R anyhow for some reason, so you certainly have to copy that particular one to your project.

Community
  • 1
  • 1
Trevor
  • 10,903
  • 5
  • 61
  • 84
2

For what's it worth, they offer a standard icon that represents this symbol. It is part of the 'Action Bar Icon Pack' form here. It's in this folder:

\Android Design - Icons 20131120\Action Bar Icons\holo_light\05_content_backspace

enter image description here

Dmitry
  • 17,078
  • 2
  • 44
  • 70
1

Example:1

If you want the action of this character of erasing, use this--

<Key android:codes="-5" android:keyLabel="⌫"
            android:keyWidth="15%p" android:keyEdgeFlags="right"
           android:isRepeatable="true"/>

Example:2

If you just want to display the character and don't need the action of the character of erasing, use this--

<Key android:codes="0x232B" android:keyLabel="⌫"
        android:keyWidth="15%p" android:keyEdgeFlags="right"
        android:isRepeatable="true"/>