错误提示空但是不会查java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
package com.baidu.adapter;
import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.cursoradapter.widget.CursorAdapter;
import com.baidu.R;
import com.baidu.bean.VideoBean;
public class VideoListAdapter extends CursorAdapter {
private View mView;
public VideoListAdapter(Context context, Cursor c) {
super(context, c);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup viewGroup) {
mView = View.inflate(context, R.layout.adapter_video_item, null);
mView.setTag(new ViewHolder());
return mView;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder holder = (ViewHolder) view.getTag();
VideoBean bean = VideoBean.getInstanceFromCursor(cursor);
holder.tvTitle.setText(bean.getTitle());
holder.tvSize.setText(String.valueOf(bean.getSize()));
holder.tvTime.setText(String.valueOf(bean.getTime()));
}
class ViewHolder{
private TextView tvTitle,tvTime,tvSize;
public ViewHolder() {
tvTitle = mView.findViewById(R.id.tv_title);
tvTime = mView.findViewById(R.id.tv_time);
tvSize = mView.findViewById(R.id.tv_size);
}
}
}