Android: add DONE key to soft keyboard deprecated attribute - android

I am trying to add a DONE key to the soft keyboard so that it will hide when the user is done adding text to an EditText.
The thing is that, from other answers here, I saw that adding the following to the XML file will do the thing:
android:imeOptions="actionDone"
android:singleLine="true"
It actually WORKS fine, and the DONE key is showed....however, Android Studio is complaining, telling that android:singleLine="true" is deprecated, use maxLines = 1.
Well, if I change android:singleLine="true" with maxLines = 1 it DOES NOT WORK and the DONE key is not showed.
Am I missing something here?? (Android Studio 2.3.3 I am using)

android:singleLine is Deprecated .You should use maxLines with inputType .
android:imeOptions="actionDone"
android:maxLines="1"
android:inputType="text"

Related

Android: imeOptions doesn't work despite using maxLines and inputType

I want the soft keyboard in my app to show Done when clicking on a particular EditText. This is how it looks
<EditText
android:id="#+id/code_editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/enter_code_textView"
android:layout_marginStart="#dimen/margin_25dp"
android:layout_marginLeft="#dimen/margin_25dp"
android:layout_marginTop="#dimen/margin_12dp"
android:layout_marginEnd="#dimen/margin_25dp"
android:layout_marginRight="#dimen/margin_25dp"
android:background="#drawable/edittext_background"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionDone"
android:textColor="#color/black"
android:textCursorDrawable="#null"
android:textSize="16sp" />
But this doesn't work. The soft keyboard enter key text doesn't change at all. I tried this on multiple devices, one Oreo and one KitKat. I also tried using singleLine attribute but that doesn't work too. What am I missing here? Thanks in advance!
There's no way to force the soft keyboard to show any key, not even the imeOptions. The keyboard app uses that as a hint- it doesn't have to honor it. And remember that every different keyboard will make different choices on whether or not to honor it. And that there is no such thing as the "default keyboard" as many OEMs replace it. Basically, you can set the imeOptions and hope it works, but there's no way to force it to work across all devices and keyboard apps.

EditText | Android TV | Softkeyboard

I have tried many different ways to get NEXT button on the keyboard, but nothing worked.
Below are few Stackoverflow links i have followed.
Setting EditText imeOptions to actionNext has no effect
imeOptions "actionNext" programmatically - how to jump to next field?
I have seen few Android TV application, using below keyboard for inputs.
Any idea how can i get it?
EDIT:
Here is my XML
<EditText
android:id="#+id/etNric"
android:layout_width="#dimen/three_hundred"
android:layout_height="wrap_content"
android:hint="#string/hint_nirc"
android:singleLine="true"
android:imeOptions="actionNext"
android:maxLines="1"
android:minLines="1"
android:nextFocusDown="#id/etCaptcha" />
you need to have to use android:nextFocusForward by the way you are also giving the id in a wrong way. and I believe the real problem is also with that way of giving id. although you can use nextFocusDown too
Use #+id/ instead of #id/
android:imeOptions="actionNext"
android:nextFocusForward="#+id/yourNextEdittext"
And you need to specify the inputType="yourInputType" also to make an edittext work.

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!!

How to make an EditText selectable but not editable on Android Ice Cream Sandwich?

I have a ListView in Activity, and in each item , I insert an EditText for show my text.
I need drag the handle to select text & copy the text, but can not edit text.
On Android ICS, How can I do this?
text.setTextIsSelectable(true) requires API 11. For those using lower API's:
In xml use:
android:inputType="none"
android:textIsSelectable="true"
This will make your EditText uneditable but selectable.
I think you could override the onKeyDown() method, make it do nothing but return true. It should catch the keypresses from the keyboard and negate them before they can go into the text in the EditText.
You might also try setting editable to false like this
android:editable="false"
on the EditText in your xml layout. However I am not certain if this will let you still highlight and copy, but it is worth a shot.
I resolved this problem.
Just set TextView like this:
text.setTextIsSelectable(true);
Althouth android:editable is deprecated and Lint suggests to use inputType, It doesn't seem to work. So android:editable="false"is apparently the best possible solution for all android versions.
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:editable="false"
android:textIsSelectable="true"
tools:ignore="Deprecated" />

Android Ice Cream Sandwich Edittext: Disabling Spell Check and Word Wrap

Whilst testing on the Android Emulator running Android 4.0 (Ice Cream Sandwich), I have noticed that the Edittext does some quite strange things.
Firstly, it underlines every word identified as "misspelt" in red. How do I disable this?
Secondly, although in the layout XML I have specified android:scrollHorizontally="true" word-wrap is enabled: how do I disable this as well? Here is the Layout XML code for the Edittext:
<EditText
android:id="#+id/editor"
android:layout_width="40dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="#+id/toolbar"
android:layout_toRightOf="#+id/toolbarleft"
android:paddingBottom="0dp"
android:paddingRight="0dp"
android:scrollHorizontally="true"
android:text=""
android:inputType="textMultiLine" >
<requestFocus />
</Edittext>
Here is an example of the spell checker I need to disable:
(source: abstract-thoughts.com)
Thanks very much!
Disabling Spell-Checking
In order to get rid of spell checking you must specify the EditText's InputType in the XML as the following:
android:inputType="textNoSuggestions"
However, my EditText needed also to be multiline, so I have added the following line to the EditText's XML:
android:inputType="textMultiLine|textNoSuggestions"
Disabling Word-Wrap
As noted, the XML attribute android:scrollHorizontally="true" does not work. However, strangely, if it is done through Java it does work. Here is the necessary code to achieve no word wrapping:
mEditText.setHorizontallyScrolling(true);
Disabling Spell-Checking in EditText.
In Android 4.0+ sometimes I get a red underline in my Textview so i add the property ...
android:inputType="textNoSuggestions"
textNoSuggestions: to indicate that the IME should not show any
dictionary-based word suggestions.
Here is a list of possible properties that we can define in :
android:inputType
Disabling Word-Wrap
remember that the property android:scrollHorizontally="true" doesn't work, so this is the solution:
mEditText.setHorizontallyScrolling(true);
In your Java class you can add to the Edittext object...
wire1type = (EditText)findViewById(R.id.wire1type);
wire1type.setInputType( ~(InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) );
This clears out the autocorrect flag and will work in API 4.
android:inputType="textMultiLine|textPhonetic"
removed all red underlines for me.
android:inputType="textMultiLine|textNoSuggestions"
produces compilation error.
I use Android API 1.6.
Disabling the spell checker for general text input via code:
mEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
remove android:inputType="" and all should be well.
To disable line wrapping you have to wrap (pun not intended) your EditText with an HorizontalScrollView and set your layout_width to match_parent.

Categories

Resources