试图在空对象引用上调用虚拟方法'void android.widget.TextView.setText(java.lang.CharSequence)'
这是一个Sqlite数据库,我想在textView中显示表
公共类SalesAdaptor扩展了ArrayAdapter {
Context context ;
int resourse;
public SalesAdaptor(@NonNull Context context, @LayoutRes int resource, @NonNull List<Sales> objects) {
super(context, resource, objects);
this.context=context;
this.resourse=resource;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
convertView = LayoutInflater.from(context).inflate(R.layout.listview_sales,parent,false);
TextView tvName = (TextView)convertView.findViewById(R.id.name_Sales);
TextView tvPhone = (TextView)convertView.findViewById(R.id.price_Sales);
Sales sales = getItem(position);
tvName.setText(sales.getName());
tvPhone.setText(String.valueOf(sales.getPhone()));
return convertView;
}}
该行中的错误(tvName.setText(sales.getName());)