views:

935

answers:

3

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 add a button that when pressed, the virtual keyboard shows up?

+2  A: 

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.

bdls
Thanks this pointed me in the right direction
Tyler
A: 
Christopher
Long press on menu was only intended to be a last resort compatibility thing for applications that at the time didn't know about soft keyboards. Applications written today should not rely on it. Because it is a compatibility mode, it puts the keyboard up in a different state than you problem expect -- for example the user needs to explicitly dismiss it rather than following the normal auto-dismiss rules while navigating through the UI.
hackbod
Thanks for the clarification (from an Android no less! ;)). So what would be the recommended UI solution for the original question? An explicit search/filter text box as bdls mentioned?
Christopher
Adding a EditText box seems to work. I found a question at http://stackoverflow.com/questions/1737009/answer-to-making-a-nice-looking-listview-filter-on-android (the first answer) that gives a nice tutorial I'm following.
Tyler
+6  A: 

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);
Mark F Guerra