Prevent user from changing input method - android

Is it possible to prevent a user from changing input method/keyboards?
I know it's not allowed by default but maybe with some security/IT device administration feature it is possible?
I've been looking around but couldn't find a definitive answer.

If you want to add some constraint that, this specific EdiText wont must raise a special type of keyboard (number pad / text) to type in. Add the following parameter in the EditText block layout/xyz.xml.
android:inputType=""//your specific type gies here e.g "number" "textUri" ...
details
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="142dp"
android:layout_marginTop="145dp"
android:ems="10" android:inputType="number">
you can also change it from the properties view by selecting appropriate EditText.

As far as the search I performed suggests - there is no such way to prevent users from changing input method.

Related

Android: How to remove customize keyboard button from keyboard?

Please find below the screenshot wherein the circular box shows the customize button option.
XMl Code:
<EditText
android:id="#+id/et_cost_per_mile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:hint="Cost Per Mile(₤)"
android:inputType="numberSigned"
/>
All I want to remove :: button from keyboard.
You have change input type like..
android:inputType="phone"
You can not. This is your android keyboard app and you cant change it. The keyboard settings can be modified in the android settings. But obviously it depends on the user, not the developer.
The only way I think it will allow you to do that is that you include in your app a fake numeric keypad as a layer (Similar to the keyboard that appears when you have to type the pin of the app of your bank). However, I don't think this is worth it. With...
android:inputType = "numberSigned"
you are already blocking the user from entering letters or other characters, even if they change their keyboard.

Android EditText doesn't show keyboard hint if use more than one inputType attribute

I'm trying to have an Edit text with keyboard hints and auotcorrection for words (such as when you write a message in whatsapp).
This is my code:
<EditText
android:id="#+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="20dp"
android:layout_weight="1"
android:background="#color/white"
android:ems="10"
android:inputType="textCapSentences|textMultiLine|textAutoCorrect|textAutoComplete"
android:scrollHorizontally="false"
android:hint="#string/note_content"
android:textColor="#color/black_text" />
According with the documentation it should work but it doesn't.
I've also tried using the deprecated android:autoText="true".
I need all the functionallity specified in the InputType
Edit:
After some try I discovered that if I set only one attribute without problem but if I set all of what I need nothing work correctly.
Edit 2:
What I want to obtain is something like the Whatsapp editbox where you write your message.
Maybe it has to do with the input type, have you tried single combinations?
Using a combination of textAutoCorrect and textAutoComplete might not always work

disable "spell checking" on textView

This is more a 'is there a more appropriate way' question as I have found a work around.
Some of my table headers are being picked up as spelling errors and underlined in red. Of course, that is not what I would like to see. I have found that using
android:inputType="textNoSuggestions"
does disable the spell check markings. I find it odd (bug?) that this is necessary as the docs state:
inputType: The type of data being placed in a text field, used to help
an input method decide how to let the user enter text.
and there is no input associated with just textView. So is this the only/more appropriate way of avoiding the spell check and also, is this a bug that it is spell checking non-input fields?
UPDATE: per request this is sample xml
<TextView
android:text="ID#"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:typeface="monospace"
android:textSize="14sp"
android:digits="4"
android:textAlignment="gravity"
android:layout_weight="5"
android:gravity="left"
android:singleLine="true"
android:phoneNumber="true"
android:inputType="textNoSuggestions|none">
</TextView>
First, I would try removing the android:digits, android:phoneNumber, and android:inputType attributes.
All of those are more intended for use with fields that allow input (such as EditTexts). It also doesn't look like you are using the android:digits attribute correctly, as the string you provide defines the only allowable characters.
In essence, this combination of attributes is telling Android that your TextView accepts input in the form of telephone numbers that contain only the number 4, that this TextView doesn't accept input of any type, and Android should not provide spellcheck suggestions.
If you are setting the content of the TextView yourself, there really is no reason to try to restrict the content of the TextView with flags such as android:phoneNumber since you are the one controlling that.
I know this is an old thread but removing the following from content XML worked for me:
android:autoText="true"
On later android studio versions try:
android:autoText="true"
inside of the (or any input) in the xml.
On newer versions try:
android:inputType="textNoSuggestions"

Phone pad and Qwerty keypad in android

I am looking to implement both phone pad and keypad in Android.As, per my requirement when the EditText is selected a default phone pad should be shown. But the user must be able to input alphabets also. Please suggest me a way to implement this.
<EditText
android:id="#+id/editTextref1"
android:layout_width="210dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:ellipsize="start"
android:hint="#string/custom1"
android:imeOptions="actionNext|actionDone"
android:inputType="text"
android:nextFocusDown="#+id/editTextref2"
android:shadowDy="10"
android:textColor="#383838"
android:textSize="14sp"
android:textStyle="bold"
android:maxLength="15"
android:typeface="serif" />
I would like to make an assumption that it's impossible to do that in a simple and elegant way. The problem is that you input type is InputType.TYPE_CLASS_TEXT and it cannot be changed to InputType.TYPE_CLASS_NUMBER because you need to input letters as well.
The problem is that input method checks the type of input and gives you the appropriate keyboard with numbers or alphabet depending on the type of the field input type. If you ask input method to give you number keyboard and you have your EditText in focus, you cannot force the input method to switch to alphabet keyboard in your code. I may be wrong but this is what I think.
The question is whether you can ask any third party input method to give you different keyboard while editing text - I think you cannot do this in your code. Input method will give you numbers or alphabet depending on your EditText but you cannot switch them dynamically because input method is not aware of your design issues. The only way you can do this is to make your own input method that allows you to switch numeric and alphabet keyboards dynamically.

Warning on EditText

I'm trying to define an EditText but this warning is shown:
This text field does not specify an inputType or a hint.
The code in main.xml is:
<EditText android:id="#+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/textTest" />
How can I fix it?
You could add a hint :
android:hint="This will appear to the user if he didn't enter something yet in the EditText"
and a inputType so you could present to the user a better suited soft keyboard for the text he is suposed to enter in the EditText:
android:inputType="number"
will present a soft keyboard with only numbers and various signs.
Those are just warnings, you could ignore them but is better for the user to implement them.
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
>
I think You should add input type.......
This is a known issue. Sometimes it doest work with changing to:
android:inputType="text"
I got it to work by setting:
android:inputType="textNoSuggestions"
Hope this helps
Above all are the solutions but before that you should understand what does that warnig mean.
Hint:- Hint is the text shown to user before writing anything over.
For eg. if you are putting a edittext where you want user to add his
name then you can write
<Edittext
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="Enter Name"/>
Input Type:- This is the xml tag that is to be used within edittext to let edittext to follow that particular restriction. if you are giving inputtype:number then user would be able to enter only numbers. There are several input type fields are there for that you can refer official developer site.

Categories

Resources