AutoCompleteTextView with keyboard done button and maxLines - android

I am trying to implement AutoCompleteTextView with multiline text and with keyboard done button. But done button does not show on keyboard (shows enter button). Same thing i have tried with android:singleLine="true" and text comes in single line with done button.
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edt_border"
android:cursorVisible="true"
android:maxLines="4"
android:hint="Enter your location"
android:imeOptions="actionDone"
android:textColor="#color/text_color"
android:textColorHint="#color/lblColor"
android:textSize="#dimen/text_size_large" />

Add android:imeActionLabel="Done" into your xml code
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:hint="Enter your location"
android:imeOptions="actionDone"
android:imeActionLabel="Done"
android:singleLine="true" />

android:inputType="text" works.
<AutoCompleteTextView
android:id="#+id/txtVillageName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:hint="#string/location_hint"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="#color/text_color"
android:textColorHint="#color/lblColor"
android:textSize="#dimen/text_size_large" />
Set HorizontalScrolling and MaxLines
mAutocompleteTextView.setHorizontallyScrolling(false);
mAutocompleteTextView.setMaxLines(Integer.MAX_VALUE);
It works

Related

android:imeOptions="actionNext" does not go to the next EditText

I have encountered a strange behaviour of android:imeOptions="actionNext". When I press next on the keyboard it actually navigates out of the AutoCompleteEditText but doesn't focus on the next one. I am using the same setting for my other EditTexts and it works fine.
Here is the .xml code:
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="#dimen/login_form_height"
android:hint="#string/prompt_email_username"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:padding="#dimen/login_form_padding" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="#dimen/login_form_height"
android:hint="#string/prompt_password"
android:imeActionId="6"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:padding="#dimen/login_form_padding" />
So when I press next it leaves "#+id/email" but doesn't focus on "#+id/password".
Any ideas?
android:singleLine="true" or android:inputType="text" can solve your problem
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="#dimen/login_form_height"
android:hint="#string/prompt_email_username"
android:singleLine="true"
android:inputType="text"
android:imeOptions="actionNext"
android:maxLines="1"
android:padding="#dimen/login_form_padding" />

textPassword not hiding text android

<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="Password"
/>
This is the code I have in my xml file, the line android:inputType="textPassword" from my understanding is supposed to make the text entered in the field appear hidden. When run on and android device the text is not hidden.
Try this :
<EditText
android:layout_height="wrap_content"
android:gravity="center"
android:password="true"
android:layout_width="match_parent"
android:id="#+id/password"
android:hint="password"
android:maxLines="1">
</EditText>

android:nextFocusDown doesn't work

I designed a layout with four EditText and i want to facilitate the navigation of them. I understand the use of android:nextFocusDown but i'm not able to get it to work. I also setted the ´ImeOptions´ to actionNext, but on the softpad I neither see the right icon.
My XML snippet:
<EditText
android:id="#+id/reservation_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourName"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/reservation_surname" >
</EditText>
<EditText
android:id="#+id/reservation_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourSurname"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/reservation_email"
android:nextFocusUp="#+id/reservation_surname" />
<EditText
android:id="#+id/reservation_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:hint="#string/yourEmail"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:nextFocusDown="#+id/reservation_notes"
android:nextFocusUp="#+id/reservation_email" />
<EditText
android:id="#+id/reservation_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edit_text_reservation"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:nextFocusUp="#id/reservation_notes" />
I had a similar issue, where nextFocus* simply did not work. In your case..
going from
<EditText android:id="#+id/reservation_name"...
android:nextFocusDown="#+id/reservation_notes"
to
change surname's id to NOT have a "+" i.e.
<EditText android:id="#id/reservation_surname"
this way you are
no creating a new reference to that tag.
This will now work.

How can I default to the alphabet keypad on focus of an EditText view?

My scenario:
I have 2 EditText:
<EditText
android:id="#+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
android:inputType="textPassword"
android:maxLength="8"
android:singleLine="true"
android:layout_below="#+id/add"/>
<EditText
android:id="#+id/edt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
android:inputType="textPassword"
android:maxLength="8"
android:singleLine="true"
android:layout_below="#+id/edt1"/>
When edt1 is focused, I input number(keyboard shows number) then I next edt2, keyboard still displays number.
I want to keyboard change number to qwerty keyboard.
How can I do this?
UPDATED: I mean: qwerty keyboard always show when EditText is focused.
Thanks all!
Remove android:digits from both. In first EditText use android:inputType="number" and in second one use android:inputType="text"
Use this :
<EditText
android:id="#+id/edt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="number"
android:maxLength="8"
android:singleLine="true"
android:layout_below="#+id/add"/>
<EditText
android:id="#+id/edt2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="text"
android:maxLength="8"
android:singleLine="true"
android:layout_below="#+id/edt1"/>

Single line EditText in Android

I am trying to make the edittext single line. The edittext does comes up as single line but on pressing enter it the cursor comes to the second line and I need to stop this. The singleLine attribute is deprecated so I do not want to use that.
<EditText
android:id="#+id/txtSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:drawablePadding="5dp"
android:lines="1"
android:maxLines="1"
android:inputType="none"
android:scrollHorizontally="true"
android:paddingLeft="5dp"
android:textSize="12sp" />
Can someone let me know what am I goind wrong over here ?
Set android:inputType to something different than "none", use "text", "number" or whatever should be entered in the EditText. This way you can make the EditText single-lined. (Of course you shouldn't use "textMultiLine" then ;))
Use this
android:singleLine="true"
instead of,
android:lines="1"
android:maxLines="1"
Change,
android:inputType="none"
to
android:inputType="text" or android:inputType="number"
according to your requirement.
use this code :
<EditText
android:id="#+id/Et_loginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/layout_bg"
android:hint="Email Address"
android:singleLine="true"
android:ellipsize="end"
/>
This alone is enough to make single line in EditText.
<EditText
android:id="#+id/fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:inputType="text"/>
android:inputType="text" alone solves the single line in EditText.
You need to choose your desired inputType as per your requirement.
change the android:inputType="none"
<EditText
android:id="#+id/txtSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:drawablePadding="5dp"
android:maxLines="1"
android:inputType="none"
android:scrollHorizontally="true"
android:paddingLeft="5dp"
android:textSize="12sp" />
to
<EditText
android:id="#+id/txtSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:drawablePadding="5dp"
android:maxLines="1"
android:inputType="text"
android:scrollHorizontally="true"
android:paddingLeft="5dp"
android:textSize="12sp" />

Categories

Resources