I have a ListView and it is possible to use the hardware keyboard to filter out items. However what should I do for phones that don't have a hardware keyboard and only a virtual one? Is there a way to开发者_Go百科 add a button that when pressed, the virtual keyboard shows up?
I was able to toggle the on-screen keyboard using the code below. I hope this is useful to someone.
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
One suggestion could be to just use a text entry box (EditText). That way a user can in theory type more than one character to narrow the search (and see what they've typed). To display the on-screen keyboard, all they need do is touch in the textbox. If that box was named "Search" or something similar, I believe it would be more intuitive to a user than a button.
There's a convention (for which maybe someone else can provide a reference — I couldn't find anything quickly) that holding the Menu hardware button brings up the soft keyboard.
Though this is seemingly device dependent. I know it works on the G1, but on my HTC Hero it doesn't work on the home screen (though HTC seem to have messed up a few shortcuts, like holding the Home button).
Anyway, I know other apps like ConnectBot mention and employ this convention for bringing up the virtual keyboard.
Holding the menu-button seems to no longer work in Android 4.0 (IceCreamSandwich). This breaks filterable lists in lots of applications where the user now has no way of filtering the list anymore and needs to eyeball-grep through long, long lists.
精彩评论