在Android TimePicker禁用键盘输入键盘输入、Android、TimePicker

2023-09-04 03:37:08 作者:谁的青春不二逼

我开发并使用1.6 SDK的Andr​​oid应用程序。我使用的是 TimePicker ,我不想软键盘来了,当你点击了 TimePicker 。我只希望 TimePicker 使用加号和减号按钮来改变。我已经使用 Android的尝试:作为焦点=假安卓focusableInTouchMode =假希望那些会做,但他们似乎并没有做任何事情。有没有办法做到这一点?

I'm developing and Android app using the 1.6 SDK. I'm using a TimePicker and I don't want the soft keyboard to come up when you click on the digits in the TimePicker. I only want the TimePicker to be changed using the plus and minus buttons. I've tried using android:focusable="false" and android:focusableInTouchMode="false" hoping those would do it, but they didn't seem to do anything. Is there a way to do this?

推荐答案

尝试使用:

myTimePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);

禁用注重文本视图内部NumberPickers的

to disable focus on the text views of the internal NumberPickers