Is it possible to set EditText only accept unicode characters in android? - 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.

Related

Android EditText inputType textShortMessage

What is the purpose of inputType textShortMessage? How will this affect my application? Do certain keyboards, Android versions or applications treat this specially, or differently from just type text?
Not that much difference between text and textShortMessage. While developing the Android Source, google developers felt to create two different class for two different cases. textShortMessage and textLongMessage both inherits the behaviour of text with some different attributes.
There could be so many types of input for a EditText. Android Developer made it easier for us to define the behaviour of a specific EditText.
textShortMessage is for: Variation of TYPE_CLASS_TEXT: entering a short, possibly informal message such as an instant message or a text message.
It means when we use textShortMessage as input type the EditText will open the alphabetic keyboard but the EditText will not be Expanded. If you change it to textLongMessage the EditText will be expanded for multiline text input.
SOURCE: http://developer.android.com/reference/android/text/InputType.html
One difference :
android:inputType="textShortMessage|textMultiLine"
Will give you the smiley button in preference to the enter key.
android:inputType="textMultiLine"
Will give you the "enter" key again.

Android EditText accept 2 values only

I want an EditText to accept two characters only, a one(1) and a zero(0). I was reading about input filters and know how to accept numeric values only but what about specifying which characters to accept.
Can someone please give me an example as to how this is done?
You may need to use something like TextWatcher, inside TextWathcer onTextChanged, if entered value is not either 1,0 display message.

HTML/ASCII Symbols in TextView?

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.

EditText Input type Issue

There is a name EditText in my screen. I want to accept only alphabets means from a-z,A-Z
and should not accept numbers, special chars.
I'am using inputtype="textPersonName" for that but its notworking, it accepts means showing all numbers, chars etc..
For phone field inputtype="phone" is working it accepting means showing numbers in field` only.
Why like that?
Your best bet is to use an InputFilter to restrict the characters that are permitted in your EditText control. You should be able to easily adapt the answer from How do I use InputFilter to limit characters in an EditText in Android? to do what you require.
You will need to subclass EditText and detect key events.
Reject any character other than a-zA-Z
This is the only way to limit the acceptable characters.
A person's name could contain a number so textPersonName is working correctly.
Try using TYPE_TEXT_VARIATION_PHONETIC

Restrict EditText to accept only Urls in Android

I am writing an application in which I need to restrict EditText to accept URLs only. How can this be done in Android?
Open the Properties of your EditBox. Property InputType offers you a list of checkboxes, and one of them is textUri.
It is also working with EditTextPreference although is not shown as property.

Categories

Resources