这是我的适配器类:-
public class CustomAdapter extends BaseAdapter {
Context c;
CustomAdapter(Context c)
{
this.c=c;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 3;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final int pos=position;
LayoutInflater inflater=LayoutInflater.from(c);
View v=inflater.inflate(R.layout.layout_list_item, parent, false);
ImageButton image_button=v.findViewById(R.id.imagebutton);
image_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(c, "Image Button clicked:" + pos, Toast.LENGTH_SHORT).show();
}
});
return v;
}
}
如何使所有图像按钮可点击?我尝试搜索答案,并根据此处给出的答案:如何在我尝试过的列表视图中使图像视图可点击,但只有我的第一行按钮是可点击的。请帮忙。