谁能告诉我如何为gridview中的图像设置标签和getTag。我已经编写了以下代码,但它不起作用。以下代码是否正确?
int jj=100;
for(int j=0;j<imageid.length;j++)//imageid is the array of drawable images
{
griview1.getChildAt(j).setTag(jj);
System.out.println(g.getChildAt(j).getTag());
}
这是我的 getView 方法
public View getView(int arg0, View arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
ImageView imv;
if(arg1!=null)
{
imv=(ImageView)arg1;
}
else
{
imv=new ImageView(cont);
imv.setLayoutParams(new GridView.LayoutParams(40,40));
imv.setScaleType(ScaleType.CENTER_CROP);
imv.setPadding(0,0,0,0);
}
}
imv.setImageResource(imageid[arg0]);
return imv;