[Android] Allowing the user to enter a filter for a ListView

Back in Using an ArrayAdapter to Control a ListView’s Data, I wrote about filtering a ListView using its setTextFilterEnabled method. One of the comments reminded me that that not all devices have a physical keyboard and the virtual keyboard does not always show when entering the filter. For devices that do not have a physical keyboard, you could ask the InputMethodManager to display the virtual keyboard:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(getListView(), 0);

Read more of this post

Advertisements