Android Universal Adapter

Source: Internet
Author: User

I. Demand analysis

In the normal Android development process, the ListView, GridView adaptation of the writing is a very cumbersome and very repetitive things, every time need to consider performance optimization, item writing, get network pictures when the information of the confusion and so on, so consider writing to implement a generic adapter, The main features to consider:

(1) Adaptive item layout file, each use only need to pass in the layout ID number;

(2) To achieve the performance tuning of list lists, the ability to reuse item, so that the loading speed of the list greatly improved;

(3) can get the picture loading list directly from the network, here consider only need to pass in the image URL address, namely can realize the picture loading and the picture cache;

(4) easy to call;

This is my GitHub address for implementing a Universal adapter: Bash here



Where Generaadapter is the Universal adapter library, directly add a reference to eclipse (do not know to add the reference to Baidu), sample is to call this library file example.

Two. Calling methods

The invocation method is extremely simple, similar to the usual use of adapter, with the following main steps:

(1) Create a new item layout file, which is no different from your usual new layout;

(2) Create a new item class, here as the item item for the universal adapter, a Irem class is a piece of data

(3) define a list<item>, as the data for the universal adapter.

(4) New generaviewadapter<Item>, it will automatically inherit convert Method

For more details, please refer to Sample class Click to open link

The effect of the final example is this:




This is a feature that requires only 5-6 lines of code.

GitHub Address: Bash here


Android Universal Adapter

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: info-contact@alibabacloud.com 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.