I have an edittext that I want to accept positive and negative numbers.
It works phone on my phone, the keyboard shows the "-" sign, however it doesn't work on some phone whereas the "-" doesn't show up on their keyboard. See the attached images. How to fix it so that it works on all Android phones. I set the edittext to android:inputType="numberDecimal|numberSigned" The first image is on my phone whereas the 2nd image shows the user's phone and he's having problem entering the "-" sign. He uses Android version 5.0.1.
<EditText
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:inputType="numberDecimal|numberSigned"
/>
Thank you.
Moving my comment to the answer:
I can see the - on both images. Probably on the lower one you need to hold the button for it though.
It worked, holding the button selects the -.
On the second keyboard the - can be found as option on the ) key. So you did everything right. Setting android:inputType="numberDecimal|numberSigned" should suffice. But eventually you might find keyboards not handling these types correctly. But then there's nothing you could do about it anyway.
Related
In my Android App, I want to let user to type Full Name at one point to an EditText. There I need the following behaviour
1). Should NOT allow user to type invalid characters. For that I was using the following
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
2). The keyboard should have the "ActionNext" to easily move to next Field. For that I was using the following
android:imeOptions="actionNext"
But when I specify digits as above, it looses the ActionNext and instead get Enter Key (move 2nd line)...
My full xml is as follows,
<EditText
android:id="#+id/editText_FullName"
android:layout_width="300dp"
android:layout_height="40dp"
android:inputType="textCapWords"
android:maxLength="40"
android:layout_marginStart="10dp"
android:textSize="16sp"
android:typeface="normal"
android:longClickable="false"
android:lines="1"
android:scrollHorizontally="false"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
android:imeOptions="actionNext"/>
I found after searching in google it saying to use android:singleLine="true" to fix the issue. Yes that fix issue but this attribute is deprecated and and Android Studio suggests to use android:maxLines="1" which again NOT fix the issue and loose ActionNext in Keyboard. Basically instead of ActionNext I still see Enter key (move next line) option.
Has anyone got a solution for this. Thanks
Edits
I could use regular expression validation or register the EditText to a KeyListener. But looking for a pure xml solution.
I have a standard straight forward EditText, I want to show the dictionary suggestions on top of this EditText so I did this in the XML:
<EditText
android:id="#+id/messaging_messageEdit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:layout_weight="85"
android:background="#drawable/clanz_edit_text_holo_dark"
android:ems="10"
android:hint="Type your message here..."
android:singleLine="true"
android:inputType="textAutoComplete"
android:textColor="#dedede" >
</EditText>
I thought that the inputType parameter would take care of the auto dictionary view. On my phone (Nexus Android 5.1) the dictionary view appears but is blank. On a Genymotion emulator (Android 4.1.1) it does not display at all.
What am I missing?
This can be one solutions if you are looking for AutoComplete TextView.
<AutoCompleteTextView
android:id="#+id/from_station"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/enter_start"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColorHint="#color/transparent_black" />
You can also set threshold value using paramters.
Need to set adapter values at runtime.
If I understand correctly you want the keyboard to have auto correction right?
According to the Android developers website:
Can be combined with text and its variations to specify that this
field will be doing its own auto-completion and talking with the input
method appropriately. Corresponds to TYPE_TEXT_FLAG_AUTO_COMPLETE.
This is not what you're looking for. You are probably looking for textAutoCorrect which is this according to the Android developers website:
Can be combined with text and its variations to request
auto-correction of text being input. Corresponds to
TYPE_TEXT_FLAG_AUTO_CORRECT.
I've made a lot of apps and never used one of those though. It just auto corrects if you have a normal EditText.
I had the same problem not getting keyboard suggestions on some of my EditText views. Please pay attention there is a difference between autoComplete text views and getting keyboard suggestions while typing! They happen in two different places, first one inside the AutoCompleteTextView the other one on top of your keyboard while typing.. (for example you type te => it suggests "tea teaspoon teapot" to make your life easier.)
To achieve that I had to turn off the input types that I was setting programmatically and when you do so, the default behavior is back and that means getting keyboard word suggestions:
// etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
I tried the following but I still did not get a keyboard suggestions:
etFieldValue.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
at the end I commented all the above and it worked just fine!
here I also found that someone else had the reverse problem meaning they wanted to disable this functionality and they suggested to use the code that I had commented! read here
I am doing an app that involves getting input from the user, and so I want to be as minimalist as possible. I am looking for a way to place what should be written in a number box like this:
+----------------------------+
Enter number of days
+----------------------------+
in a grayed out manner, that dissapears when a number is placed inside.
I tried to google it, but since I couldn't find the right word (Not a native speaker), I couldn't find the right results. So I come here for help.
use android:hint="Enter number of days"
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter number of days"
android:inputType="number"
/>
See here for the "hint" usage: http://developer.android.com/reference/android/widget/TextView.html#getHint()
I am fairly new to java and android. at the moment i am studying java at school. i just started working in this calculator just to get my hand in android developing. my problem at the moment is that when i deploy the app to the emulator (phone size 480x800) looks like Pic 001, but when i deploy it to my Kindle fire 1st gen (1024x600 i believe) looks like Pic 002. how can i make it so it look the same in every phone.
XML File
In order to have your buttons fill the entire width of your screen, put this in your tags Button:
android:layout_width="0dp" android:layout_weight="1"
instead of :
android:layout_width="80dp"
If you want the buttons to be higher :
- In your tags Button change android:layout_height="80dp" to android:layout_height="match_parent".
- In your tags LinearLayout which contain your buttons change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="1".
- In your tag TextView change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="X" where X is the value that gives you the right proportions.You will have a warning telling your that nested weight are bad for performance but it's the only way I know to do this.
In general, if you want a component to fill the empty space, set the width or height to 0dp and add a weight. The weight will define the proportions of the elements which want to fill the space.
I hope it will help you.
I've tried every variation I can think of for input type and raw input type, but I can't get it so that the number keyboard shows first, but then allows you to toggle back to the text keyboard. Right now if you specify text|number, or number|text, the letters always show first, and then you have to toggle to the number keyboard. Is it possible to do the opposite?
Per my research and Bert B.'s comment, there is no way to do this cross-device compatible.
Just add
android:inputType="number"
into your EditText field. This should automatically trigger the keyboard to show the number pad first.