Android custom ListView series adapter mode (old university IT)

Source: Internet
Author: User

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.




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)


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.