Inside the activity, a ListView is set up to show three sections: fruits, vegetables, and meats. The SimpleSectionsAdapter takes two resource IDs of the layouts that the adapter should inflate for headers and content. The header layout in this example is a custom layout centering a single TextView, while the content layout is a standard layout from the framework (android.R.id.simple_list_item_1). Since the adapter is abstract, we are required to provide a definition of onSectionClick(), which in this case just displays the name of the selected item in a Toast.
1-10. Creating Compound Controls
Problem
You need to create a custom widget that is a collection of existing elements.
Solution
(API Level 1)
Create a custom widget by extending a common ...
Get Android Recipes: A Problem-Solution Approach for Android 5.0, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.