Enter key event not working on Numeric Input field

2019-07-17 08:15发布

问题:

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.

回答1:

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



回答2:

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"