public void update() { // 查询数据库记录 , 恢复查询历史记录 List<XCSearchRecordModel> searchRecordBeans = dao.queryAll(XCSearchDao.SORT_DESC); if (searchRecordBeans != null && searchRecordBeans.size() > 0) { xc_id_fragment_search_record_clear_button.setText("清空所有历史记录"); } else { xc_id_fragment_search_record_clear_button.setText("暂无历史记录"); } adapter.update(searchRecordBeans); adapter.notifyDataSetChanged(); xc_id_fragment_search_record_listview.setSelection(0); }
@Override public void onClick(View v) { int id = v.getId(); if (id == R.id.xc_id_fragment_search_record_clear_button) { if ("清空所有历史记录".equals(xc_id_fragment_search_record_clear_button.getText())) { dao.deleteAll(); // 查询数据库记录 List<XCSearchRecordModel> searchRecordBeans = dao.queryAll(XCSearchDao.SORT_DESC); if (searchRecordBeans != null && searchRecordBeans.size() > 0) { xc_id_fragment_search_record_clear_button.setText("清空所有历史记录"); } else { xc_id_fragment_search_record_clear_button.setText("暂无历史记录"); } adapter.update(searchRecordBeans); adapter.notifyDataSetChanged(); } } else if (id == R.id.xc_id_fragment_search_record_close) { if (OnCloseClickListener != null) { OnCloseClickListener.close(); } } }