android - NumberPicker in AlertDialog always activates keyboard. How to disable this? -
to all,
i trying simple numberpicker work in alertdialog. problem whenever increase/decrease value in numberpicker, keyboard activates.
there many posts describing problem, none of suggestions work. have tried:
android:configchanges="keyboard|keyboardhidden"
and
inputmanager.hidesoftinputfromwindow(currentview.getwindowtoken(), 0);
and
getwindow().setsoftinputmode( windowmanager.layoutparams.soft_input_state_always_hidden);
i have tried calling these functions before , after initialization (dialog.show ()), on keypress events (using listeners obviously), etc. no luck far.
the complete code:
popup.xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <numberpicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/mynumber" android:configchanges="keyboard|keyboardhidden" /> </relativelayout>
and calling function:
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();
any appreciated
barry
actually, although solution above works perfectly, there easier way.
picker.setdescendantfocusability(numberpicker.focus_block_descendants);
this needed. anyway, replies!!!! :-)
Comments
Post a Comment