下面是我设置列表视图的代码。我想在列表视图上实现一个点击事件,但它不起作用。我已经在清单中为列表视图设置了可点击属性。此外,我的列表视图位于相对布局内,而此相对布局位于线性布局中。我的 list_details 在相对布局中有 textview 和 imageview。你能帮我解决这个问题吗?提前致谢。
public class ListImageBaseAdapter extends BaseAdapter {
...
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = l_Inflater.inflate(R.layout.list_details, null);
holder = new ViewHolder();
holder.txt_itemName = (TextView) convertView.findViewById(R.id.name);
holder.itemImage = (ImageView) convertView.findViewById(R.id.photo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
System.out.println(titles.length);
holder.txt_itemName.setText(titles[position]);
holder.itemImage.setImageResource(imgid[position]);
holder.itemImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("here1");
}
});
holder.txt_itemName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("here2");
}
});
return convertView;
}
...