android - softkeyboard keeps hiding after expanding Searchview programmatically (w/ Search Button) -
i using searchview
support library in appcombat actionbar. on emulator works intended. can open clicking menu item or using search button on device , keyboard shown.
@override public boolean onkeydown(int keycode, keyevent event) { if(keycode == keyevent.keycode_search) { if(!menuitemcompat.isactionviewexpanded(searchitem)) { menuitemcompat.expandactionview(searchitem); } else menuitemcompat.collapseactionview(searchitem); } return super.onkeydown(keycode, event); }
on expanding set saved text.
menuitemcompat.setonactionexpandlistener(searchitem, new menuitemcompat.onactionexpandlistener(){ @override public boolean onmenuitemactioncollapse(menuitem item) { // todo auto-generated method stub return true; } @override public boolean onmenuitemactionexpand(menuitem item) { searchview.onactionviewexpanded(); // initialize searchview searchview.setquery(searchtext, false); searchview.requestfocus(); return true; } });
problem:
on hardware device (htc desire hd, android 2.3), when press device's search button searchview expands , softkeyboard shows part of second , hides again. clicking menuitem works fine , shows keyboard intended. there seems method hiding keyboard again after focusing searchview. tried several stuff (setonquerytextfocuschangelistener
manually showing softinput) none seem work on device.
i hope got solution. thanks
it looks searchview has lost focus after setting searchtext. try adding before calling requestfocus.
searchview.setfocusable(true);
Comments
Post a Comment