我如何获取已动态设置的ImageView资源名称?
以下是图片适配器代码:
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) { // if it's not recycled, initialize some
// attributes
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.gridxml, null);
imageView = (ImageView)v.findViewById(R.id.icon_image);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
//imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(5, 5, 5, 5);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
imageView.setTag(mThumbIds[position]);
System.out.println(mThumbIds[0]);
System.out.println(mThumbIds[1]);
System.out.println(mThumbIds[2]);
System.out.println(mThumbIds[3]);
System.out.println(mThumbIds[4]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = { R.drawable.directory_xml,
R.drawable.news_xml, R.drawable.calendar_xml,
R.drawable.facilities_xml, R.drawable.employee_handbook_xml,R.drawable.settings_xml };
}
}