主要是要注意在父ListView的适配器里判断子ListView的position是否为空,如果为空则不加载
if(crimes.get(position)!=null)
{
holder.txtshow.setAdapter(new CarMessgeAdapter(crimes.get(position)));
}
完整的适配器代码
package com.example.tangweilong.demo;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by liying on 2016/11/20.
*/
public class MyAdap extends BaseAdapter {
private ArrayList<Friend> friends;
private ArrayList<Crime> crimes;
public MyAdap(ArrayList<Friend> friends,ArrayList<Crime> crimes) {
this.friends = friends;
this.crimes = crimes;
}
@Override
public int getCount() {
return friends.size();
}
@Override
public View getV