我需要更改方法onListItemClick() 来删除列表中的项目.. 想法?我不知道如何使它适应我的课堂。我有一个 Db 类 I 和一个 Helper 类。
这是代码:
Cursor cursor = db.rawQuery("select * from " + PRODUCT_TABLE, null);
setListAdapter(new CursorAdapter(this, cursor, true) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent){
TextView textView = new TextView(ProdottiSelectionActivity.this);
return textView;
}
@Override
public void bindView (View view, Context context, Cursor cursor){
TextView textView = (TextView) view;
textView.append(cursor.getString(1));
textView.append("\n");
textView.append(cursor.getString(2));
textView.append("\n");
textView.append(cursor.getString(3));
textView.append("\n");
textView.append(cursor.getString(4));
}
});
}
@Override
protected void onDestroy(){
super.onDestroy();
dbHelper.close();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
setResult(1, new Intent(String.valueOf(id)));
finish();
}