Edittext jumps to next edittext, but wrong - android

I need help with my app. This is my xml file with Relative layout, and I need to jump to the next edittext after pressing Enter key.
But there is a problem, if I'm writing to the editTextKm and press Enter key, it jumps to the editTextFullTank, but I need to jump to the editTextManufactYear. How to do it?
<EditText
android:id="#+id/editTextSPZ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:maxLength="11"
android:inputType="textCapCharacters"/>
<EditText
android:id="#+id/editTextKm"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editTextSPZ"
android:inputType="number"
android:maxLength="7"/>
<EditText
android:id="#+id/editTextManufactYear"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/editTextKm"
android:layout_alignBottom="#+id/editTextKm"
android:layout_alignParentRight="true"
android:layout_marginRight="2dp"
android:layout_toRightOf="#+id/editTextKm"
android:inputType="number"
android:maxLength="4" />
<EditText
android:id="#+id/editTextFullTank"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editTextKm"
android:inputType="number"
android:maxLength="3"/>
<EditText
android:id="#+id/editTextReserveTank"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/editTextManufactYear"
android:layout_toRightOf="#+id/editTextFullTank"
android:inputType="number"
android:maxLength="3" />
<EditText
android:id="#+id/editTextNote"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/editTextFullTank"
android:capitalize="sentences"
android:singleLine="false"/>

For further details you can consult Anddroid Developer blog.
Focus movement is based on an algorithm which finds the nearest neighbor in a given direction. In rare cases, the default algorithm may not match the intended behavior of the developer. In these situations, you can provide explicit overrides by using these XML attributes in the layout file:
android:nextFocusLeft="reference"
android:nextFocusRight="reference"
android:nextFocusUp="reference"
android:nextFocusDown="reference"

add the attributes:
android:nextFocusDown="#id/your_next_edit_text_to_focus" to each EditText according to what you need.
You can also use :
android:nextFocusUp="#id/your_next_edit_text_to_focus"
android:nextFocusLeft="#id/your_next_edit_text_to_focus"
android:nextFocusRight="#id/your_next_edit_text_to_focus"

Related

How to maintain text padding on EditText when there are multiple lines

For an application that I'm working on, I have an editText that I allow users to input data into. I have defined padding on the input that is not maintained when multiple lines of text are entered in. For example:
After adding a second line of text:
As more and more lines are added, I'm also seeing that the position of the edittext in the parent view gets lower and lower:
My XML for the editText is as follows:
<EditText
android:id="#+id/message_edit"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/dp_8"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:background="#drawable/someBackground"
android:paddingLeft="#dimen/dp_12"
android:paddingRight="#dimen/dp_3"
android:elevation="3dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Type here"
android:lineSpacingExtra="#dimen/dp_4"
android:textColor="#color/black"
android:textSize="#dimen/sp_17" />
I assume that both issues are related given but i'm not sure what the underlying cause is.
Instead android:paddingLeft and android:paddingRight use only android:padding to add padding on all side. Check below:
<EditText
android:id="#+id/message_edit"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/dp_8"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:background="#drawable/someBackground"
android:padding="#dimen/dp_12"
android:elevation="3dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="Type here"
android:lineSpacingExtra="#dimen/dp_4"
android:textColor="#color/black"
android:textSize="#dimen/sp_17" />
Result:

Edittext View One line

Can someone point me on how to limit the edittext as one line only?
screenshot:
my xml:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:maxLines="1"
android:gravity="fill_vertical" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:scrollHorizontally="false"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:maxLines="1"
android:inputType="textPersonName"
android:gravity="fill_vertical" />
Just add into your XML-File android:maxLines="1"
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:id="#+id/textView_data2"
android:textSize="20sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:inputType="text"
android:imeOption="actionNext"
android:gravity="fill_vertical" />
android:inputType="text"
android:imeOption="actionNext"
these two lines are the catch. you better use actionDon in imeOption
i.e.,
android:imeOption="actionDone"
use this and you are all good :)
P.S. there are multiple types of imeOption provided by android. We usually use these imeOptions for our softKeyboardInput where we need to change enter button of our keypad to anything else.
e.g., actionDone : DOne button
actionNext :Go to next editBox and etc,
These imeOption only works with inputType="text|number|..i.e. you need to specify a input type for using imeOption.
Hope it will help you :)

edit Text is not accepting numeric Keyboard in expendable ListVIew

here is my code in xml
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="0.00"
android:inputType="number|numberDecimal"
android:layout_marginRight="5dp"
android:textSize="16dp"
android:id="#+id/et_childinput1"
android:background="#ffffff"
android:imeOptions="actionDone"/>
i also tried android:numeric="decimal" which is diffracted how can i do this.
i come to know that
android:numeric
android:phoneNumber
android:inputMethod
android:capitalize
android:autoText
are replaced by android:inputType
the code above work for me in Edit Text but when it come inside expendable list-view child ,the issue arise there the keyboard arise but again full keyboard is replaced by numeric in a instance
any help will be appreciated
<EditText
android:id="#+id/phoneNoRegEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ems="15"
android:hint="Phone"
android:inputType="phone"
android:maxLength="10"
android:singleLine="true"
android:textColorHint="#color/blue_home"/>
It may help you
If you want only Numbers then it may help you
<EditText
android:id="#+id/phoneNoRegEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ems="15"
android:hint="Phone"
android:inputType="number"
android:digits="01234567989"
android:maxLength="10"
android:singleLine="true"
android:textColorHint="#color/blue_home"/>

Letters pop up en Android keyboard

I have these EditText in my app:
<EditText
android:id="#+id/text_url_servidor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:hint="#string/text_url"
android:singleLine="true"
android:textSize="7pt" />
and
<EditText
android:id="#+id/login_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/login_username"
android:hint="#string/login_password"
android:password="true"
android:singleLine="true"/>
When I run the app, the first one shows the letters pop-up, but not the second one. They are in different layouts (xml). Both are inside a RelativeLayout. The only difference is that the first one are shown in a Dialog. Why second one is not showing letters as pop-up? Thanks.
I think it may be because of android:password="true" remove it and try

EditText warning in android app development

While declaring EditText in xml file, I was warned exactly as given below
No label views point to this text field with an android:labelFor="#+id/#+id/start" attribute
EditText code is
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/start"
android:hint="#string/edit_message" />
I also had no idea what this error message was trying to inform me to do!
Thankfully I found an explanation: http://thecodeiscompiling.blogspot.com/2013/12/android-labelfor-waning-fix.html
the warning is telling you the EditText field does not have a TextView that can be read to a user when accessibility is turned on, since you haven't specified one with the android:labelFor attribute.
Solution for this warning:
No label views point to this text field with an android:labelFor="#+id/#+id/editText1" attribute
When you drag and drop and Text Fields into Graphical Layout you get this above error .
The generated code looks like this:
<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="31dp"
android:layout_marginTop="154dp"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
Solution :
add this label "android:labelFor="#+id/editText1" as shown below .
<EditText
android:id="#+id/editText1"
android:labelFor="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="31dp"
android:layout_marginTop="154dp"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
Use id like following in your editText.
android:id="#+id/editText1"
And then if you want to set labelFor then use
android:labelFor="#id/editText1"
Use android:labelFor="#+id/start" instead of android:id="#+id/start".

Categories

Resources