Recently, I used asynchronous loading and dynamic UI refreshing for a project. After reading the source code of the 2.2 System Image Library, I feel that it is well written. At the same time, I took the ListView out and studied it and made a note.
First:
1. A large number of adapter modes are used in Android, such as ListView and GridView.
I understand the so-called adapter mode as a power adapter or adapter.
The power adapter outputs voltages that are not suitable for machine operation as the appropriate voltages for the machine. The adapter is better understood, and the unmatching plug and socket are connected together. The adapter mode is similar to this. It combines two irrelevant classes so that they can be used together.
Shows the structure of the adapter in Android. Other adapter classes, such as SimpleAdapter and SimpleCursorAdapter, inherit BaseAdapter directly or indirectly. The Adapter used for custom ListView must inherit the BaseAdapter through the following methods: getCount (), getItem (int position), getItemId (int position), getView (int position, view convertView, ViewGroupparent)
Why?
Note that both the Spinnerdapter and ListAdapter interfaces inherit the Adapter interfaces. BaseAdapter is an abstract class that implements the preceding two interfaces, but it does not implement the four methods mentioned above. Therefore, when constructing a BaseAdapter subclass, you must implement the four interface methods that are not implemented. In fact, there are many such examples in Android. When inheriting a class, you will be allowed to Override some methods by default. These methods are interface methods not implemented in the parent class.
After the four methods are rewritten, the adapter can work with the control to associate the data with the control UI.
From thick and thin hair, water comes to the fore