【发布时间】:2013-12-23 11:29:04
【问题描述】:
我在我的 GridViewAdapter 类中创建了一个 imageView:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Try to reuse the views
ImageView view = (ImageView) convertView;
boolean checked = (mCheckBox==null)?false:(((CheckBox) mCheckBox).isChecked());
// if convert view is null then create a new instance else reuse it
if (view == null) {
view = new ImageView(Context);
//view.setTag(ViewId(), "imageViewGRID");
view.setId(R.id.1);
Log.d("GridViewAdapter", "new imageView added");
}
但我不确定如何使用 .setId 以便我可以在这一行的另一个类中使用此 imageView:
ImageView imageView1 = (ImageView)v.findViewById(R.id.1);
有人可以解释一下这是如何工作的吗?
请注意,我也尝试过:
view.setTag("imageView4Grid");
与
ImageView imageView1 = (ImageView)v.findViewWithTag("imageView4Grid");
但我得到一个错误
【问题讨论】:
标签: android