Android 自定义ArrayAdapter NullpointerException

Android 自定义ArrayAdapter NullpointerException,android,arraylist,nullpointerexception,android-arrayadapter,Android,Arraylist,Nullpointerexception,Android Arrayadapter,我的自定义阵列适配器有问题: 在我的getView()方法中有一个NullpointerException 我已经发现,ArrayList似乎不是问题所在,因为它在没有适配器的情况下工作正常 我的适配器 public class ArrayAdapterCusPostlist extends ArrayAdapter<Post> { Context mContext; ArrayList<Post> postListe; public Arr

我的自定义阵列适配器有问题:

在我的
getView()
方法中有一个
NullpointerException

我已经发现,
ArrayList
似乎不是问题所在,因为它在没有适配器的情况下工作正常

我的适配器

public class ArrayAdapterCusPostlist extends ArrayAdapter<Post> {

    Context mContext;
    ArrayList<Post> postListe;


    public ArrayAdapterCusPostlist(Context mContext, int layoutResourceId, ArrayList<Post>pList) {

        super(mContext, layoutResourceId, pList);
        postListe = pList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView==null){
            LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
            convertView = inflater.inflate(R.layout.rowpost, parent, false);
        }
        Post curpost=postListe.get(position);

        if(curpost!=null){
        TextView textViewItem = (TextView) convertView.findViewById(R.id.nickname2);
        textViewItem.setText(curpost.getName());
        textViewItem.setTag(curpost.getName());
        }

        return convertView;

    }

}

谢谢

上下文mContext未初始化

 Context mContext;
 LayoutInflater inflater;
 public ArrayAdapterCusPostlist(Context mContext, int layoutResourceId, ArrayList<Post>pList) {
 super(mContext, layoutResourceId, pList);
 this.mContext =mContext;
 inflater = LayoutInflater.from(context); // initialize here. no need for context initialization if you have this here.
 }  
 Context mContext;
 LayoutInflater inflater;
 public ArrayAdapterCusPostlist(Context mContext, int layoutResourceId, ArrayList<Post>pList) {
 super(mContext, layoutResourceId, pList);
 this.mContext =mContext;
 inflater = LayoutInflater.from(context); // initialize here. no need for context initialization if you have this here.
 }  
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if(convertView==null){
        convertView = inflater.inflate(R.layout.rowpost, parent, false);
        holder = new ViewHolder();
        holder.textViewItem = (TextView) convertView.findViewById(R.id.nickname2);
        convertView.setTag(holder);
    }
    else
    {
          holder = (ViewHolder) convertView.getTag();
    }
    Post curpost=postListe.get(position);

     holder.textViewItem.setText(curpost.getName());
     holder.textViewItem.setTag(curpost.getName());
    }

    return convertView;

static class ViewHolder
{
     TextView textViewItem;
}
}