思路:主要是在布局中写好具体的布局种类和详情,最重要的是适配器中的操作,除了继承BaseAdapter需要重写的方法外,还要手动重写两个方法即:getTtemViewType和getViewTypeCount方法,在getTtemViewType方法中有几种布局就分几种情况然后返回,然后是getView方法中通过getTtemViewType()方法获得类型type ,在对convertView进行判空里面对各种类型分类,比如 type1 都是文字的情况,需要找到布局,然后找到布局中的ID,取得标签后需要得到存放数据的该类 ,根据类型情况给文字或图片赋值接口类得到的相应内容,如 type1 都是文字,type2 是文字和图片结合:
首先把展示的不同分类写在Layout布局中,这里有两个不同的布局
item1
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/title1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/title11"