Note that there are some explanatory texts on larger screens.

plurals
  1. PONumberPicker in AlertDialog always activates keyboard. How to disable this?
    primarykey
    data
    text
    <p>To all,</p> <p>I am trying to get a simple NumberPicker to work in a AlertDialog. The problem is that whenever I increase/decrease the value in the numberpicker, the keyboard activates.</p> <p>There are many posts describing this problem, but none of the suggestions work. I have tried:</p> <pre><code>android:configChanges="keyboard|keyboardHidden" </code></pre> <p>And</p> <pre><code>inputManager.hideSoftInputFromWindow(currentView.getWindowToken(), 0); </code></pre> <p>And </p> <pre><code>getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); </code></pre> <p>I have tried calling these functions before and after initialization (dialog.show ()), on keypress events (using listeners obviously), etc. but no luck so far.</p> <p>The complete code:</p> <p>popup.xml</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;/RelativeLayout&gt; </code></pre> <p>And the calling function:</p> <pre><code>AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); View view = getLayoutInflater().inflate(R.layout.popup, null); builder.setView (view); final AlertDialog dialog = builder.create (); NumberPicker picker = (NumberPicker) view.findViewById(R.id.myNumber); picker.setMinValue(0); picker.setMaxValue(999); dialog.getWindow(). setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.show(); </code></pre> <p>Any help appreciated</p> <p>Barry</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.
 

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