第一次用RecyclerView,求大神帮忙看下适配器错误

图片说明
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

public class CourseListRecyclerViewAdapter extends RecyclerView.Adapter{
private List mList;
private Context mContext;
private LayoutInflater mInflater;

//构造方法
public CourseListRecyclerViewAdapter(Context context, List<SearchResult> mList) {
    this.mContext = context;
    this.mInflater = LayoutInflater.from(context);
    this.mList = mList;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = mInflater.inflate(R.layout.course_list_item, parent, false);
    MyViewHolder myViewHolder = new MyViewHolder(view);
    return myViewHolder;
}

@Override
public void onBindViewHolder(MyViewHolder myViewHolder, int position) {
    myViewHolder.textView.setText(mList.toString());
}

@Override
public int getItemCount() {
    return mList.size();
}

class MyViewHolder extends RecyclerView.ViewHolder {
    public TextView textView;

    public MyViewHolder(View view) {
        super(view);
        textView = (TextView) view.findViewById(R.id.course_list_textview);
    }
}

}

1个回答

第39行,空指针,调试,看看哪个对象没有创建

qq_28186229
崔峰鸣 恩,谢谢
大约 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问