Learn Android listview together
With a small example, this paper briefly describes the relevant applications of listview in Android development, which is only for learning and sharing.
Listview is a view group that displays a scrollable item list. List items insert data from data sources such as arrays or database queries into the list through adapters, and convert the contents of each item into the view for display.
The relationship between view and ViewGroup is shown in the following figure:
The effect picture of listview is as follows:
The XML layout source code is as follows:
The binding data source code is as follows (including adding header and footer):
The event listening code is as follows:
When the list item in lisvview has multiple contents, you can use simpleadapter to realize multi column display.
The example renderings are as follows:
The steps are as follows:
1. Define a listview_ List item layout file for item.xml.
2. Associate the adapter with the layout file in the code (use list < map < string, Object > > as the data source)
3. Click the event to get the content
This article is a summary of entry-level learning knowledge. If there are deficiencies, please correct them. Thank you.