检查下面的代码它可能会帮助你。
private class ListViewAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public ListViewAdapter(Context con) {
// TODO Auto-generated constructor stub
mInflater = LayoutInflater.from(con);
}
public int getCount() {
// TODO Auto-generated method stub
return main_genral_class.review_name.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ListContent holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.review_row, null);
holder = new ListContent();
holder.img = (ImageView) convertView
.findViewById(R.id.imageView1);
holder.name = (TextView) convertView
.findViewById(R.id.textView1);
holder.check_date = (TextView) convertView
.findViewById(R.id.textView2);
holder.img.setOnClickListener(mOnTitleClickListener);
holder.name.setOnClickListener(mOnTitleClickListener1);
holder.check_date.setOnClickListener(mOnTitleClickListener2);
convertView.setTag(holder);
} else {
holder = (ListContent) convertView.getTag();
}
holder.text2.setText(main_genral_class.review_shout.get(position));
return convertView;
}
}
private OnClickListener mOnTitleClickListener = new OnClickListener() {
public void onClick(View v) {
final int position = mListView.getPositionForView((View) v
.getParent());
Toast.makeText(review_activity.this, "click on Image View",
Toast.LENGTH_SHORT).show();
}
};
private OnClickListener mOnTitleClickListener1 = new OnClickListener() {
public void onClick(View v) {
final int position = mListView.getPositionForView((View) v
.getParent());
Toast.makeText(review_activity.this, "click on Text View",
Toast.LENGTH_SHORT).show();
}
};
private OnClickListener mOnTitleClickListener2 = new OnClickListener() {
public void onClick(View v) {
final int position = mListView.getPositionForView((View) v
.getParent());
Toast.makeText(review_activity.this, "click on Date Text View",
Toast.LENGTH_SHORT).show();
}
};