public View getView(int position, View convertView, ViewGroup parent) { if (convertView != null) { view = convertView; } else { view = mInflater.inflate(。。。。。,。。。); } delButton = (Button) view.findViewById(R.id.del_btn); delButton .setTag(position+""); delButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { int index = Integer.parseInt(v.getTag().toString()); selectData = listData[index]; } } }
index就是当前item的索引