I created two EditText with these two property.
android:digits="0123456789"
android:inputType="numberDecimal"
I use Hardware Keyboard, when I perform Enter Key, focus control not shifting from one view to next view, as it happen normal in EditText case. If I remove "android:digits" property then it work properly, but here it allow to insert decimal key also, that I don't want.
I tried with "android:nextFocusDown" proerty also, but that is also not working in this case.
Any one have idea how can use Enter key event to shift focus.
use
Either
android:inputType="number"
or
android:digits="0123456789"
PS :
best one is android:inputType="number" because it will automatically open the numeric keyboard
where as android:digits="0123456789" this will open simple keyboard
Add this to the layout:
android:singleLine="true"
You don't need android:inputType="numberDecimal", since you declared only digits in the android:digits="0123456789"
Related
In Some phones when number keypad is displayed unable to go back to normal keypad because in my scenario numbers are the primary for me so need number keypad to be displayed at first go later if we want to switch to normal keypad it's not working.
Mostly I observed this issue in Lenovo phones/tablets.
Edit: Basically iam using Digitkeylistener for some seperators to get added programatically if i make use of Textkeylistener its throwing n number crashes randomnly.So I want to use Digitkeylistener but with normal keypad.
Change inputtype attribute of your Edittext in XML, to text
You can add below line in your code
For Numeric,
editText.setRawInputType(Configuration.KEYBOARD_12KEY);
For Qwerty,
editText.setRawInputType(Configuration.KEYBOARD_QWERTY);
This is only to set input type but you can change keyboard and will not restrict Edittext to enter number only.
You can add below line in your XML for getting general keyboard:
android:inputType="text"
<EditText
android:layout_width="match_parent"
android:inputType="text"
android:layout_height="match_parent" />
You can add below line in your XML for getting Number keyboard:
android:inputType="number"
Can I use numberPassword as input type and still see the input?
My goal is to have a 0-9 keyboard with as few as possible other keys (that's why I prefered numberPassword over phone), but the user should still be able to see what he just typed.
This is what I have, but right now the passwords are hidden behind asterisks.
android:digits="1234567890"
android:inputType="numberPassword"
Note: I also tried setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD), which made the input visible, but changed the keyboard from numbers-only to a regular keyboard. I need they keyboard to display numbers-only though.
In Java, just do this:
edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());
If you wanted to hide the password later on, you would just do this:
editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
This did the job:
uEditText = (EditText) findViewById(R.id.editText);
uEditText.setTransformationMethod(null);
There are different ways you can solve this problem
You can use use TextInputEditText with TextInputLayout like below
<android.support.design.widget.TextInputLayout
android:id="#+id/etPasswordLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
android:layout_marginBottom="#dimen/login_spacing_bottom">
<android.support.design.widget.TextInputEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/fragment_login_password_hint"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
With passwordToggleEnabled, you can toggle between asterisk and password values
You can use the Transformation class to toggle password asterisk and value like below
edittextObject.setTransformationMethod(PasswordTransformationMethod.getInstance());
You can create a custom keyboard with the values you want to display in your keyboard. You can see how to achieve this in this tutorial I wrote about custom keyboard
i have several EditText in my App. If you hit the Enter Key you can tab to the next EditText without a problem but i would like to change the Enter Key so that this button doesn't shows the Enter Simbol but instead it shows "Next" or "Done". i tried many things but without any results. Here is the XML code for my EditText:
<EditText
android:id="#+id/et_nt_name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top"
android:imeOptions="actionNext|flagNoEnterAction"
android:imeActionLabel="Next"
android:singleLine="true"
android:inputType="textShortMessage"
/>
it is the case that some soft keyboards actually change the default text on the enter key by design, so it may not be your fault that it's not showing what you want it to show. the functionality should be the what you programmed it to do, though.
i recommend you switch to the default keyboard (long press on any edit text, then select input method) to verify that it's showing the correct text, and don't care about the what the other soft keyboards look like .
if your phone didn't come with the default soft keyboard, the Android emulator is your best friend.
Add this to your EditText,
android:imeOptions="actionDone"
I have a edit text, whose input type is number.
in emulator its working fine i.e, showing the num-pad as soft keypad.
but in the device its showing alphabets keyboard why?
<EditText android:layout_width="110dp"
android:layout_height="30dp" android:id="#+id/phone"
android:layout_alignParentRight="true" android:background="#drawable/edit_text_bg"
android:inputType="number" android:maxLength="10"
android:paddingLeft="4dp" android:textColor="#1b0a00"
android:layout_marginRight="8dp"/>
Thanks in advance....!
So from what i've observed setting the inputType to phone should solve the problem . But try a different device to check if ur code works by giving input as number before moving to this option .
I think you must change inputType
FROM :
android:inputType="number"
TO:
android:inputType="phone"
When you give the InputType as number there is a completely new keyboard that gets loaded very different to what you will get by pressing the corner button on your normal keyboard to get numbers . Only certain phones/android versions(i think 2.2+) have this separate keyboard . For the ones that dont have this , The normal keyboard is shown and manual switching has to be done .
It could be that the device you're testing has some sort of custom keyboard enabled by default that doesn't support a number pad. Try changing the keyboard settings to the standard keyboard on the device and see if it works.
Is there a way in android to invoke a numeric only keypad, i.e. a virtual keypad that contains only the numbers 0 to 9 and a "." sign?
Try doing android:inputType="phone" ?
Basically, you need what Peter Boughton said.
More generally, if you need to invoke different type of keyboard, depending on the input you expect on your EditText component, you should use the IMF (Input Media Framework) and different IMEs (Input Media Editors).
You can customize not only the input symbols, but also the layout of the keyboard in your application, auto-completion and other options.
You may want to read this post in the Android Developers Blog:
Updating Applications for On-screen Input Methods
If you're talking about restricting input to 0-9 + "." for an EditText box, I use the android:numeric="decimal" attribute in the layout XML.
<EditText android:numeric="decimal" />
If you're working with dynamically generated EditText views, the relevant method to call on it is
setKeyListener()
Make sure you only have:
<EditText android:numeric="decimal" />
and not both:
<EditText android:numeric="decimal"
android:digits="0123456789." />
The latter, ie using both numeric and digits was not working for me. However, using only numeric works.
<EditText android:numeric="decimal" />
only does not affect keypad to convert into decimal.
Instead, use:
<EditText android:inputType="phone" android:numeric="decimal"></EditText>
This will show the numeric keypad only.