Enter key event not working on Numeric Input field?

我们两清 提交于 2019-12-11 03:49:00

问题


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"



来源:https://stackoverflow.com/questions/17944655/enter-key-event-not-working-on-numeric-input-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!