Restrict EditText to accept only Urls in Android - 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.

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.

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 custom IME for specific InputType

I am currently developing an IME which generate me a dynamic password based on my input.
I used the sample SoftKeyboard in order to undertake this project.
When I need to type a password, I just need to change the Input Method and for now, it seems to be ok.
My question is quite simple. Is there a way to allow this IME only when the InputType is a password type like (InputType = TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
Or would there be a method to specify a specific keyboard (in this case my IME) when InputType is a password type?
Thank you !
Nope. There's 2 things that control the IME. First, the user sets a single default IME for the phone. There is no way to split this up by type or anything else. Second, the app can request a specific IME for a text field. Usually this is done only if the app itself is providing that IME. There is no way for a keyboard to make itself the default, or for it to override the default for a type.

Create Android preference in settings to set password

I would like a setting in preferences that allows the user to create a password. The perfect example is in the Play Store. In settings you click on Password and a dialog box pops up with an EditText field with a password field that hides the characters. How would you do that?
I'm pretty sure this is not EditTextPreference. Is this a custom preference? How would you make this? Can I get a sample for the XML part of it?
I'm pretty sure this is not EditText preference
EditTextPreference would work. Quoting the documentation:
This EditText can be modified either programmatically via getEditText(), or through XML by setting any EditText attributes on the EditTextPreference.
So adding android:password="true" as part of your preference XML should work.
That being said, you are certainly welcome to create your own custom DialogPreference for this.
Using intents
In some cases, you might want a preference item to open a different activity instead of a settings screen, such as a web browser to view a web page. To invoke an Intent when the user selects a preference item
it's available at android guide, check this link
http://developer.android.com/guide/topics/ui/settings.html#Intents

Custom dictionary for EditText

Is it possible to create a custom dictionary for an edittext? In other words, can I create a custom list and have the edittext only suggest names from that list? I don't need it popping up useless word suggestions when the user is inputting specific names of people.
Please refer to this link.
https://developer.android.com/resources/samples/SearchableDictionary/index.html
They would have implemented content provider to provide a custom input to the quicksearch. You can try taking a similar approach where in you can make a query and update the result when a user enters each alphabet in your EditText box.
Use AutoCompleteTextView and provide your dictionary in the adapter.
http://developer.android.com/guide/topics/ui/controls/text.html

Categories

Resources