android:imeOptions. Button not showing up - android

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

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.

Android: add DONE key to soft keyboard deprecated attribute

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"

Setting up EditText with "url" inputType

I am trying to make an EditText such that, when I click it, a keyboard containing ".com" appears, because a URL is to be entered into the EditText.
I tried to use this:
android:inputType="textUri"
but it is not working. How do I do it?
try this one
<EditText
android:id="#+id/edt"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:inputType="textWebEmailAddress"
/>
android:inputType="textWebEmailAddress"
use this property for that.
You can use inputType as textWebEmailAddress or textEmailAddress. Specs say it is device dependent but honestly I did not find any difference. Purpose of using this is you can use the # and .com keys in the keypad. I tried both on samsung Galaxy S5 and keypad is the same.

Edit Text without Autocorrect

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.

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