【发布时间】:2013-12-04 22:42:36
【问题描述】:
我在 listview 中有 imageview。 我正在使用自定义适配器来绑定数据。 我在 imageview 单击时显示相同列表视图的 textview 文本的吐司。 但它显示随机文本视图文本。 这是我的代码
localfilename=tvlfilename.getText().toString();
ImageView thumb_image=(ImageView)vi.findViewById(R.id.ivnotificationpreview);
thumb_image.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(mCtx, localfilename, Toast.LENGTH_SHORT).show();
}});
【问题讨论】:
-
这是因为ListView的回收机制。使用
setTag()和getTag()来维护被点击的确切数据。 Have a reference blog of mine -
那我现在该怎么办?
-
您可以发布更多代码 - 您在哪里检索点击时的项目索引?