0
我需要更改方法onListItemClick()刪除列表上的項目..想法? 我不知道如何適應我的課程。我有一個Db班和一個助手班。從列表視圖中刪除項目
下面是代碼:
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();
}