Generic filtering search Activity

As discussed earlier in the chapter, there are times where you have a predefined list of objects and you want your user to select one of them. The list is too large for the user to scroll through (for example, a list of all the countries in the world), but it's also a defined list, so you don't want them to be able to select free text.

In this case, a filterable ListView is generally the best suited option. While the ListView class has filtering capabilities, it doesn't work very well (if at all) on devices without hardware keyboards. For this reason, it's wise to make use of an EditText widget to allow the user to filter the contents of the ListView.

This sort of requirement is a very common one, and so in this ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.