这里是代码:
public View getView(final int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.search_results_item_remove_view, null);
list = data.get(position);
TextView title = (TextView) vi.findViewById(R.id.item_text); // title
ImageView remove = (ImageView) vi.findViewById(R.id.item_remove);
remove.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
db.deleteContact(list.getID());
data.remove(position);
notifyDataSetChanged();
Toast.makeText(activity, "Please wait. updating list...",
Toast.LENGTH_LONG).show();
}
});
// Setting all values in listview
title.setText(list.getName().toString());
return vi;
}
任何帮助将不胜感激。谢谢。
答案 0 :(得分:1)
使用项目OnClickListener:
public OnClickListener mOnTitleClickListener3 = new OnClickListener() {
public void onClick(View v) {
final int position = list_v
.getPositionForView((View) v.getParent());
list = data.get(position);
db.deleteContact(list.getID());
data.remove(position);
notifyDataSetChanged();
Log.d("you are click on Ratings","you are click on Ratings");
}
};