我想从 listview 孩子的 onClick 事件中获得点击的行。我能够在该事件中获得点击的项目但没有点击行。请帮我解决问题。
提前致谢!。我的代码是
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Holder holder = new Holder();
pos = position;
if(convertView == null)
{
System.out.println(position);
convertView= inflater.inflate(R.layout.list_layout,(ViewGroup)parent.findViewById(R.layout.list_layout));
holder.form_name = (TextView) convertView.findViewById(R.id.list_text);
holder.form_details = (TextView) convertView.findViewById(R.id.button_text);
holder.form_details.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println(pos);
//Here i am able to get clicked view but pos has always
// last value
System.out.println("button view clicked for "+cipt_list.get(pos).cipt);
}});
System.out.println(holder.form_name);
convertView.setTag(holder);
}
else{
holder = (Holder) convertView.getTag();
}
ciptDetails cipt = cipt_list.get(position);
holder.form_name.setText(cipt.cipt);
return convertView;
}