4.5.3. Fields of Class MainActivity

Figure 4.19 contains class MainActivity’s static and instance variables. The String constant SEARCHES (line 31) represents the name of the file that will store the searches on the device. Lines 33–34 declare EditTexts that we’ll use to access the queries and tags that the user enters. Line 35 declares the SharedPreferences instance variable savedSearches, which will be used to manipulate the key–value pairs representing the user’s saved searches. Line 36 declares the ArrayList<String> that will store the sorted tag names for the user’s searches. Line 37 declares the ArrayAdapter<String> that uses the contents of the ArrayList<String> as the source of the items displayed in MainActivity’s ListView.


30      // name of SharedPreferences XML file that stores the saved searches
31      private static final String SEARCHES = "searches";
32
33      private EditText queryEditText; // EditText where user enters a query
34      private EditText tagEditText; // EditText where user tags a query
35      private SharedPreferences savedSearches; // user's favorite searches
36      private ArrayList<String> tags; // list of tags for saved searches
37      private ArrayAdapter<String> adapter; // binds tags to ListView
38


Fig. 4.19 | Fields of class MainActivity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.134.229