Edit Text without Autocorrect - android

I want an EditText without the autocorrection.
I have set the textNoSuggestions inputType, as shown:
<EditText
android:id="#+id/txtTarga"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Targa"
android:inputType="textNoSuggestions|textCapCharacters" >
The capitalize flag works, but it is still autocorrecting.
How can I disable it?

inputType textVisiblePassword will do the trick (most of the times, because as Commonsware pointed out, it stays a request and you'll might find yourself finding devices where it works, and devices where it doesn't work)

android:inputType="textNoSuggestions"
according to this, inputType attribute may or may not be supported by some devices .
However, this seems to work more often
android:inputType="textNoSuggestions|textVisiblePassword"

You could try by code, something like this:
EditText edittext = (EditText)findViewById(R.id.txtTarga);
edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

In Xml
<EditText
android:id="#+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:hint="password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:singleLine="true"
/>
In java source code
// casting done from EditText to TextView
TextView mPassword = (TextView) findViewById(R.id.password);
No idea why is this. But works fine.

textNoSuggestions does not work in every keyboard. The accepted answer inputType="textVisiblePassword" works but it removes emoji's from most keyboards.
I found that setting inputType="textUri" works and keeps the ability to add emojis.

Related

How to stop edittext auto suggestion with email input type Programmatically in Android

How to disable auto suggestion with input type : textEmailAddress, while using like below the auto suggestion will appear, exactly want stop auto suggestion with email keyboard.
Used Code
<EditText
android:hint="Logesh"
android:inputType="textEmailAddress|textNoSuggestions|textMultiLine "
android:layout_width="match_parent"
android:importantForAutofill="no"
android:layout_height="match_parent" />
and i tried below also
<EditText
android:hint="Logesh"
android:inputType="textEmailAddress|textVisiablePassword"
android:layout_width="match_parent"
android:importantForAutofill="no"
android:layout_height="match_parent" />
when using textVisiblePassword that input of keyboard "#" not shown.
Thanks in advance !
Add this one in your EditText -
android:inputType="textFilter|textEmailAddress|textNoSuggestions"
and remove android:importantForAutofill="no"
Can you try by adding textFilter property in your android:inputType?
android:inputType="textFilter|textEmailAddress|textVisiablePassword"
android:inputType="textNoSuggestions"
Android has great documentation, check the InputType section of TextViews here
android:importantForAutofill="no"
android:inputType="textEmailAddress"
These two lines worked for me.
I’m not sure it’s exactly what you were looking for, but I needed a way to keep the keyboard layout with the # and shortcuts, but avoid saving the email in the keyboard suggestions for privacy purposes, as it’s for a kiosk app.
In the end I managed it by using:
android:importantForAutofill="no"
android:inputType="textWebEmailAddress"

android editText multiline return to line not working with swiftkey

I have the following edit text
<EditText
android:id="#+id/txtMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:gravity="start"
android:inputType="text|textMultiLine"
android:minHeight="90dp"
android:singleLine="false"
android:textColor="#color/textColor" />
Every reference shows that the code is correct and in fact the text wraps to multiline. But the enter key doesn't go to the new line when i use swiftkey keyboard (Google keyboard works fine)
any idea of how to solve this issue ?
Thanks
Have you considered switching to the default keyboard. It might solve your issue.
See this answer Set EditText to be Multiline(Enter is carrige return) and not display suggestions for more details.

EditText textCapSentences does not work

I try to make text starts with uppercase first letter.
Using attr inputType
<EditText
android:id="#+id/add_user_fname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_size_small"
android:inputType="textCapSentences|textPersonName"
android:capitalize="sentences"
android:layout_toRightOf="#id/user_avatar"
android:hint="#string/add_user_fname"
android:maxLength="#integer/name_max_length"
android:singleLine="true"
android:textSize="#dimen/text_size_small" />
and set in code
userFnameEditText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
but nothing works.
All of this places in DialogFragment.
Updated
I removed setInputType in code and set only inputType="textCapSentences". It works on Android 4, but doesn't work on Samsung Android 5
I had the same problem. But, I found a solution that help me: Be sure that your "Auto Capitalization" settings is checked on keyboard settings. This works on Nexus 4.
Reference: http://www.ercanbaran.com/textcapsentences-not-working/
Edited
Try it in your java file
TextView txtCapitalize = (TextView) findViewById(R.id.txtCapitalize);
txtCapitalize.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
You should add this line captilaize your letter in EditText
android:inputType="textCapSentences"
I hope this is helpful. ThankYou
To inform you android:capitalize="sentences" is deprecated, So as suggested by other answers you can either use
android:inputType="textCapSentences"
OR
android:inputType="textCapWords"
Both works ! But one for sentence and one for words.
Try this:
android:inputType="textCapSentences"
and
android:capitalize="sentences"
remove textPersonName from xml.
if you add both
android:capitalize="sentences"
and android:inputType="text", in this case it take first and input will not captalized.
android:inputType="textCapSentences"

android:imeOptions. Button not showing up

I tried setting android:imeOptions to actionSend, actionSearch. But there's no "Send" or "Search" button on the keyboard, just usual "Enter" key. I also tried setting different input types. (I'm working with HTC Sensation XL.) What's wrong?
I'd suggest switching your EditText to singleLine mode
Currently in Android Studio 2.2.3 if you use
android:singleLine="true"
IDE gives a warning that it has been deprecated use maxlines instead.
android:maxLines="1"
However maxLines does not solve the problem. The solution is to just add the attribute inputType. Example :
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/actionDoneDemo"
android:layout_below="#id/nameET"
android:imeOptions="actionDone"
android:hint="Action Done Demo"
android:inputType="text"/>
Try these actionDone imeOption doesn't work on EditText in Android 2.3
if it is not supported read How do I handle ImeOptions' done button click?. May be the HTC implemented their own soft keyboard which ignores the imeOptions
Just do in xml:
<EditText android:imeOptions="actionSearch"
android:inputType="text"/>
Happy Coding!!

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