@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(); } }
/** 初始化listView */ private void initListView() { Cursor cursor = BusDBManager.getInstance(context).getQueryBusLineHistoryCursor(); historyListAdapter = new HistoryListAdapter(context, cursor, true); mListView.setOverScrollMode(View.OVER_SCROLL_NEVER); setHeaderViewWithListView(); mListView.setAdapter(historyListAdapter); }
@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(); } }