Android Universal Adapter

Source: Internet
Author: User

I. Demand analysis

In the ordinary course of Android development. ListView, gridview adaptation of the writing is a very troublesome and very repetitive things, each time need to consider performance optimization, item writing, access to network images when the information confusion and other issues. So consider writing to implement a generic adapter that mainly considers the functionality:

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

(2) Implement performance tuning for list lists. can re-use item, so that the loading speed of the list greatly increased;

(3) can get the picture loading list directly from the network, here consider only need to pass in the picture URL address, 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


watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvsvriywlszwk=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

The Generaadapter is the Universal adapter library, directly in eclipse to add a reference to (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 usage. There are several 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>, which will inherit convert on its own initiative Method

The above details can be seen Sample class Click to open link

Finally, the effect of the sample is this:




The above only requires 5-6 lines of code, but one such function.

GitHub Address: Bash here


Android Universal Adapter

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: 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.