Bhr*_*esh -4 android arraylist nullpointerexception android-arrayadapter
您有自定义列表视图与以下代码段.
问题是当我运行代码时应用程序崩溃这是我的代码
class MyAdupter extends ArrayAdapter<String>{
Context context;
String[] title ;
String[] description;
int[] images;
public MyAdupter(Context context, String[] title, String[] description, int[] images) {
super(context, R.layout.my_simple_row,title);
this.context = context;
this.title = title;
this.description = description;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Layoutlnflater inflater = (Layoutlnflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.my_simple_row, parent, false);
ImageView imageView = (ImageView) row.findViewById (R.id.imageViewl);
TextView textTitle = (TextView) row.findViewById (R.id.textViewl);
TextView textDescription = (TextView) row.findViewById(R.id.textView2);
imageView.setImageResource(images[position]);
textTitle.setText(title[position]);
textDescription.setText(description[position]);
return row;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |