how to request focus on the second editText? - android

i want focus in the second editText ,also can make edit in the first
I have two edit text , i tried to put in the second edittext
android:focusable="true"
android:focusableInTouchMode="true"
but when tested it still focus in the firstEdit text
<EditText
android:id="#+id/editText1Price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/textView2"
android:ems="10"
android:inputType="numberDecimal" >
</EditText>
<EditText
android:id="#+id/editText2Funds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/textView4"
android:layout_toLeftOf="#+id/textView4"
android:ems="10"
android:focusable="true"
android:focusableInTouchMode="true"
android:inputType="number"
/>

this may little help you !
try this in your .java file :
EditText edittxt=(EditText)findViewById(R.id.editText2Funds);
edittxt.requestFocus();

Keep <requestFocus/> in the Second EditText.

try this,you have to add below code in which edittext you show focus..
<EditText...>
<requestFocus />
</EditText>

Related

EditText not working in text android

I'm facing an issue regarding EditText.
EditText is not working in couple of android devices when inputType:Text / TextMultiline/ TextPersonName.
but when you use inputType:Number
It works in all devices
what is the issue?
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:textIsSelectable="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
Firstly it didn't show the keyboard
then i use this
android:windowSoftInputMode="stateVisible|adjustResize"
after this i can't edit the text fields
if inputType:number then it works
One thing i want to add more is i'm using this in custom ListView
I think problem with android:textIsSelectable="true" try to remove and check
<EditText
android:id="#+id/quantity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Quantity 1Kg Meat etc"
android:focusableInTouchMode="true"
android:clickable="true"
android:inputType="text"
android:textSize="14sp"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:layout_below="#+id/line1"
android:layout_alignParentStart="true" />
android:inputType="textNoSuggestions|text"
android:focusable="true"
Working solution
If mobile text prediction is on then use above inputType to edit textfields

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"/>

Auto capitalization of first letter of edit text not working

I am trying to add EditText with inputtype = textCapWords but it is not working for me .
I have also tried textcapsentences but it is also not working.
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/d1"
android:textCursorDrawable="#drawable/custom_cursor"
android:background="#drawable/text_field_account"
android:gravity="left|center_vertical"
android:hint="#string/Last_Name"
android:inputType="se"
android:maxWidth="30dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:text=""
android:maxLength="30"
android:textColor="#color/black000"
android:textColorHint="#color/text_color_hint"
android:textSize="#dimen/font_n" />
You need to use this
android:inputType="textCapSentences"
Try This
remove android:inputType
// add this it Capitalize The First Letter Of Every Word.
android:capitalize="words"
Change the input type of your Edittext.
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/d1"
android:textCursorDrawable="#drawable/custom_cursor"
android:background="#drawable/text_field_account"
android:gravity="left|center_vertical"
android:hint="#string/Last_Name"
android:inputType="textCapSentences"
android:maxWidth="30dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:text=""
android:maxLength="30"
android:textColor="#color/black000"
android:textColorHint="#color/text_color_hint"
android:textSize="#dimen/font_n" />
Try this it may be help to you
yourEdittext.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

Android EditText keyboard newline not working (only on input view)

In the affirmation text field I press the newline button and it puts spaces.
However after I click done the field actually has the correct new lines (second screen capture).
Its not a problem with the device as it works correctly for the compose mail filed in the gmail app. Which is how I would like this to work.
<TextView
android:inputType="textMultiLine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="#string/edit_affimation"
/>
<EditText
android:id="#+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false"
>
</EditText>
Figured it out
<EditText
android:inputType="textMultiLine"
android:id="#+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false">
</EditText>
Add following attribute:
android:inputType="textMultiLine"
You can also do it programmatically:
Editext txt = (EditText) findViewById(R.id.affText);
txt.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);

Categories

Resources