17

I'm using the NumberPicker under the Android SDK level 13 inside a fragment. Works fine, but each time the activity is started the cursor is blinking behind the number. How can I get rid of the blinking cursor, I don't know why this widget has the focus. This is the xml of the NumberPicker:

<NumberPicker android:id="@+id/timer_picker_hrs"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
hoffimar
  • 543
  • 5
  • 16

3 Answers3

36

I get this solution from somewhere but I don't remember from where. This works good for me, just do this in your activity.

myNumberPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

You can also set this in XML:

android:descendantFocusability="blocksDescendants"

(Borzh comment)

Bilal Rabbani
  • 1,288
  • 14
  • 24
2

One way of removing the blinking cursor is disabling the soft keyboard for the NumberPicker. (refer to: Disable soft keyboard on NumberPicker )

Community
  • 1
  • 1
damaxxed
  • 2,464
  • 2
  • 16
  • 17
0

It's gaining focus because of child CustomEditText

you need to move focus to other view or disable soft input

se my answer for solution:

how disable focus on NumberPicker

Community
  • 1
  • 1
ceph3us
  • 7,326
  • 3
  • 36
  • 43