我无法在GridView上显示我的图片。
这是我声明我的数组列表的方式
ArrayList<Integer> arrImages = new ArrayList<>();
这是我的onCreate
int i = 0;
for (Words wd : words)
{
String log = "Id: " + wd.getId() + " ,Name: " + wd.getName();
// Writing Contacts to log
Log.d("wordList : ", log);
arrImages.add( this.getResources().getIdentifier(wd.getName(), "drawable", this.getPackageName()));
i++;
}
//gridView
gridView = (GridView) findViewById(R.id.gridView);
adapter = new MyGridViewAdapter(this, arrImages);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(this);
这是我的BaseAdapter
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
LinearLayout outerLayout;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//recycling logic
if (convertView == null)
{
convertView = (LinearLayout) inflater.inflate(R.layout.grid_images,null);
}
imageView = (ImageView) convertView.findViewById(R.id.ivGrid_images);
imageView.setImageResource(images.get(position));
return convertView;
}