HTML/ASCII Symbols in TextView? - android

Is there a way to represent special HTML characters in a EditText in Android? I want to display symbols like section signs (§), bullet points (•), degrees (°), etc.
Is there a way to do this?
Thanks!
EDIT: The original post had asked about a TextView, but my intended question is about EditTexts. I want the user to be able to press the button corresponding to the symbol they want, and the symbol will be added to the EditText, and they then resume typing.

Have you tried \u00A7 \u2022 and \u00B0 in setText?
That are unicode numbers of those characters.
For EditText, you just have to create buttons with mEditText.getText().append(character) and probably mEditText.focus().

Have you looked at the Html.fromHtml(...) methods?
Alternatively you could just use a WebView instead of a TextView and use loadData(...) to load an HTML string.

Related

Is it possible to set EditText only accept unicode characters in android?

Is it possible to make an android EditText accept only unicode characters? If so, how?
Currently, unicode only is not a restriction option for the EditText component, but you can dynamically check every symbol to see if it falls into that category or not, and if not remove it.

How to remove Android auto-suggest underlining in EditText?

I'm using an EditText to write some text. Android's auto-suggest underlines the word, until we hit space. Now, if I enter the word without the space, the resulting text has an underline. It's because I use Html.toHtml(view.getText()).
Now, there are a few answers I'll be expecting such as disabling auto-suggestion or using view.getText().toString(), but I need them both. I need the auto-suggestion feature as well as the formatting of the text. An example which solves this problem is the Gmail app. You can write whatever you want in the EditText box and it sends the email without the words being underlined.
Use this just before you getText(). This is the most straightforward and the official way.
edittext.clearComposingText();
Do it like this
android:inputType="text|textNoSuggestions"
I just came up with a solution for this. After submitting the text, just hide the keyboard, and the text underline goes away.

Android - Questions about Edit Text in WebView

I'm using a Edit Text to put in a URL to search in the Internet. But to use a URL, I need to put http:// in front of the Url. Is there a way, to hide this and use it for default?
And the other thing is to have only one single line in the Edit Text?
Thanks
Is there a way, to hide this and use it for default?
When you retrieve the value from the EditText, see if it begins with a recognized scheme (e.g., https://). If not, add it yourself, through string concatenation or StringBuilder or something.
And the other thing is to have only one single line in the Edit Text?
Use android:maxLines="1" in the <EditText> element in your layout.

Show EditText placeholder for certain amount of characters

This is a simple Android question that is hard to explain.
For an EditText field, I need 18 characters.
I limited the lenght of the edittext now with android:maxLength="18"
What I really need to do is show a dot for each character, or something like a placeholder for each character. I know you can use a real placeholder in Android, but it disappears when you start to enter your text.
Do you guys know any library or other solution for this?
UPDATE: I rather not use 18 seperate edittexts. That would be a lot of hassle to use a textwatcher on each EditText etc..
After trying out your suggestions, I found a solution of my own.
I placed two editTexts on top of each other, set the text of the top editText to 18 dots(.) and enabled to false (to get the greyish look).
I left the other editText untouched.
In code I set both the typeFaces to monospace, to each character would have the same size.
The output is an editText with a grey dot for every character, exactly what I wanted.
Thanks for the help guys, I appreciate it!

Musical note symbols on Android

I'm working on an a piano quiz app and I'm at the point where I need to write all the letter notes on the keyboard, more exactly when the user tries to guess what note was played and will press a key the musical letter will appear on that key.
This a screenshot of the app when the user touches a key:
My question is related to the musical symbol flat:
How can I achieve that symbol and implement it in the app? For example dflat is shown as "DB" and I need to rewrite it to "Dflat", flat as the musical symbol.
Edit: The letter notes are shown as text views.
Are you asking whether there is a text character for a flat symbol? If so, check here: http://en.wikipedia.org/wiki/List_of_Unicode_characters
Are you asking how to set the font to one that supports said character? If so, check out the setTypeface() method of TextView: http://developer.android.com/reference/android/widget/TextView.html
You might also consider using icons instead of text.
Edit: The unicode character for the flat symbol ♭ is 266D, and you can use unicode in Java via the \u escape character. Something like this:
sampleText.setText("\u266D");
You have to be using a font that supports that character. And more importantly, so do your users. That's why it might be a better idea to use an icon instead.

Categories

Resources