"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