Enter key event not working on Numeric Input field

2019-07-17 08:29发布

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.

2条回答
Luminary・发光体
2楼-- · 2019-07-17 08:51

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-07-17 09:03

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"

查看更多
登录 后发表回答