Android ListView Adapter Getitemviewtype and Getviewtypecount multiple layouts

Source: Internet
Author: User



"Android ListView Adapter Getitemviewtype and Getviewtypecount multiple layouts"

In the Android listview, if you want to implement a ListView layout style of multiple styles in a ListView, you need to use it in the adapter adapter of the ListView: Getitemviewtype () and Getviewtypecount (). Getviewtypecount () tells the ListView how many types of item view,getitemviewtype () it needs to load and tells the ListView what the item View style is in a location (position).
An example is given to illustrate that this example is simple with the letters A, B, C ... Grouped as data, and then there are five of data under each letter.



All code:

Package Zhangphil.listview;import Java.util.arraylist;import Java.util.hashmap;import android.app.ListActivity; Import Android.content.context;import Android.graphics.color;import Android.os.bundle;import Android.view.layoutinflater;import Android.view.view;import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.listview;import Android.widget.textview;public class MainActivity Extends the total number of types of listactivity {//Item view. Private final int view_type_count = 2;private final String data = "DATA";p rivate final String type = "Type";p rivate final int GROUP = -2;private final int ITEM = -3;private arraylist


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android ListView Adapter Getitemviewtype and Getviewtypecount multiple layouts

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.