public class SearchAutoAdapter extends BaseAdapter {
private OnClickListener mOnClickListener;
public SearchAutoAdapter(Context context, int maxMatch,
OnClickListener onClickListener) {this.mOnClickListener = onClickListener;
}
public View getView(int position, View convertView, ViewGroup parent) {
holder.addButton.setTag(data);
holder.addButton.setOnClickListener(mOnClickListener);}
Activity中
public class SearchActivity extends BaseActivity implements OnItemClickListener, CalInterface{
@Override //回调adapter中的view.click方法
public void onClick(View v) { int id = v.getId();//可以根据 R.id.delete_all形式来判断具体点击了哪一个view
data = (SearchAutoData) v.getTag(); if (data == null) { return; } else { mSearchEditText.setText(data.getContent()); mAutoListView.setVisibility(View.GONE); doSearch(); } }}