这是我的querysetobject.sql
班级
CustomList:
CustomList
这是我的public class CustomList extends ArrayAdapter<String> {
private final Activity context;
private final String[] web;
private final Integer[] imageId;
public CustomList(Activity context,String[] web, Integer[] imageId) {
super(context, R.layout.single_row, web);
this.context = context;
this.web = web;
this.imageId = imageId;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.single_row, null, true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.txt);
ImageView imageView = (ImageView) rowView.findViewById(R.id.img);
txtTitle.setText(web[position]);
imageView.setImageResource(imageId[position]);
return rowView;
}
}
数组,通过imageId
循环填充它,如下所示
while
但是当我运行它时,我发现我的while(crs.moveToNext()){
String img = crs.getString(crs.getColumnIndex("Icon"));
try
{
imageId[i] = Integer.parseInt(img);
}
catch(NumberFormatException nfe) {}
i++;
}
中的错误在我的课程结束后在我的行上说错误
CustomList
logcat:
imageView.setImageResource(imageId[position]);
答案 0 :(得分:0)
似乎imageView
或imageId
是null
。请仔细检查您是否正确设置imageId
值,single_row
布局的ImageView
ID为img
。