Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since there is no access to NumberPicker buttons, it's "impossible" to do. </p> <p>I made fast dirty hack to deal with it.</p> <p>First add focus eater to layout, in this case Button with 0 size:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;NumberPicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/myNumber" android:configChanges="keyboard|keyboardHidden" /&gt; &lt;Button android:id="@+id/myBtn" android:layout_width="0dp" android:layout_height="0dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>We need to catch event of clicking on incement/decrement buttons, I chose OnValueChangedListener, couldn't find something better.</p> <pre><code> EditText edit = null; try { final Field[] fields = picker.getClass().getDeclaredFields(); for (Field f : fields) { if (EditText.class.equals(f.getType())) { f.setAccessible(true); edit = (EditText) f.get(picker); } } } catch (IllegalAccessException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } if (edit != null) { final EditText finalEdit = edit; final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() { @Override public void onValueChange(NumberPicker numberPicker, int i, int i1) { dialog.findViewById(R.id.myBtn).requestFocusFromTouch(); imm.hideSoftInputFromWindow(finalEdit.getWindowToken(), 0); } }); } </code></pre> <p>This is not recommended solution. I hope someone would find something better. Use only for educational purpose ;-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload