【发布时间】:2019-03-14 18:05:05
【问题描述】:
我正在尝试在 android 的列表视图中显示我在数据库中的一些图像以及这部分
@Override
public View getView (int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater ();
View listViewItem = inflater.inflate (R.layout.layout, null, true);
TextView androids = (TextView) listViewItem.findViewById (R.id.tvandroidosnames);
// TextView textView = (TextView) listViewItem.findViewById (R.id.tvurl);
// textView.setText (urls [position]);
androidos.setText (androidosnames [position]);
ImageView image = (ImageView) listViewItem.findViewById (R.id.imgvw);
image.setImageBitmap (Bitmap.createScaledBitmap (bitmaps [position], 100, 50, false));
return listViewItem;
}
它给了我以下错误:
java.lang.NullPointerException:尝试调用虚拟方法'int android.graphics.Bitmap.getWidth()' 在空对象引用上
【问题讨论】:
-
你能告诉我们整个适配器的代码吗?
标签: android nullpointerexception android-bitmap