@Override public void onClick(View v) { try { BusDBManager.getInstance(context).deleteBusLineHistory(); historyListAdapter.changeCursor( BusDBManager.getInstance(context).getQueryBusLineHistoryCursor()); } catch (DbException e) { Toast.makeText(context, "删除失败", Toast.LENGTH_SHORT).show(); } }
@OnItemClick(R.id.fg_lines_listView) protected void lvOnItemClick(AdapterView<?> parent, View view, int position, long id) { /*-1 因为headerView*/ Cursor c = (Cursor) historyListAdapter.getItem(position - 1); try { BusLineBean busBeanfromCursor = BusDBManager.getInstance(context).getBusLineBeanfromCursor(c); Intent intent = new Intent(context, BusLineInfoActivity.class); intent.putExtra("busLine", busBeanfromCursor); context.startActivity(intent); } catch (DbException e) { e.printStackTrace(); } }
@Override public void onStop() { super.onStop(); historyListAdapter.getCursor().close(); }