Time for action - returning the selection

The ListItemSelectionActivity can now be used to display a list of possible items, and filter through them by typing in an EditText above the ListView. However, we have no way of letting the user actually select one of the options from the ListView in order to pass it back to our parent Activity. This requires nothing more than a simple implementation of the OnItemClickListener interface.

  1. The ListItemSelectionActivity class now needs to implement the OnItemClickListener interface:
    public class ListItemSelectionActivity extends Activity implements TextWatcher, OnItemClickListener {
    
  2. After registering as a TextWatcher in the onCreate method, register as an OnItemClickListener on the ListView:
    list.setOnItemClickListener(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.