Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of Adapter system in Android

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the use of Adapter system in Android". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the use of the Adapter system in Android"?

Let's first take a look at the Adapter system:

Public interface Adapter----0 layer (represents the hierarchy in the inheritance system)

Public interface ExpandableListAdapter--- (no hierarchy because no other interface inherits to implement it)

This is the ancestor of adapter, and other personalized adapter implements it and adds its own interface.

Public interface ListAdapter----1 layer

Public interface SpinnerAdapter----1 layer

Public interface WrapperListAdapter----2 layer (implementing ListAdapter)

The system at the above interface level is over. It can be seen that as the bridge of widgetview, adapter can only be divided into two types: ListAdapter and SpinnerAdapter and ExpandableListAdapter. In other words, all widget is based on the three view forms of list and spinne and ExpandableList.

Because in actual use, we need to add data to the Adapter, and the adapter presented in the form of an interface cannot save the data, so the Adapter is transformed into a class schema.

Public abstract class BaseAdapter----2 layer (implements ListAdapter and SpinnerAdapter)

Appears in the form of abstract classes to construct the top-level abstraction under the type, including List and Spinner

Public class ArrayAdapter----3 layer

Public class SimpleAdapter---3 layer

Public class CursorAdapter----3 layer (there are subclasses after CursorAdapter that will not be discussed here)

With the basic system in place, let's take a look at what methods are available in the top-level Adapter (list only the commonly used ones):

Abstract Object getItem (int position) abstract int getCount () abstract long getItemId (int position) abstract int getItemViewType (int position) abstract View getView (int position,View convertVeiw,ViewGroup parent) so far, I believe you have a deeper understanding of "what is the use of the Adapter system in Android". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report