EditText in AlertDialog does not look like an EditText in Dialog - android

I have a normal Dialog with an EditText:
http://imageshack.com/a/img673/4729/UPuwot.png
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Player 1 name"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"/>
And I have an AlertDialog with an EditText:
http://imageshack.com/a/img537/416/jmkW6r.png
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:hint="custom score"
android:ems="10"
android:id="#+id/editText5"
android:textAlignment="gravity"
android:layout_gravity="center_horizontal"/>
How can I make both look the same. I prefer the AlertDialog's layout. I use AppCompat 21.
Moreover, I think i can remember that in the beginning of programming, all EditTexts looked the same. Then I started playing around with themes and now there is this problem.

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

EditText textAllCaps not working with textIsSelectable

I have a TextView in my layout:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:text="Hello"
/>
textAllCaps works good, no problem. But when I try to make text selectable by adding textIsSelectable
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textIsSelectable="true"
android:text="Hello"
/>
textAllCaps not working. It seems like these two attributes can't work together properly. Have you any suggestions why it happens and how to make text both all caps and selectable (I'm interested in a most clear way, not setting text change listener and capitalizing text manually). I'll be appreciate for any suggestions, thank you.
Can you try this in Activity :
edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
I found one solution. It's to use AppCompatTextView and app:textAllCaps:
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textAllCaps="true"
android:textIsSelectable="true"
android:text="Hello"
/>
I'm not sure this is the best solution (AppCompatTextView docs tells to use this component only when creating custom components), but it works.
You can set inputType property as "textCapCharacters" for Uppercase keyboard as default
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapCharacters"
/>
use like this
<android.support.design.widget.TextInputLayout
android:id="#+id/input_postcode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapCharacters" //use this line dont forgot
android:textColorHint="#color/white"
app:hintTextAppearance="#style/TextAppearance.App.TextInputLayout">
<EditText
android:id="#+id/et_postcode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="#color/white"
android:gravity="center_vertical"
android:hint="Post code "
android:inputType="text" //dont use hereinputtype
android:imeOptions="actionNext"
android:maxLength="4"
android:padding="10dp"
android:textAllCaps="true"
android:singleLine="true"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="15sp" />
</android.support.design.widget.TextInputLayout>

Edittext jumps to next edittext, but wrong

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"

Categories

Resources