我想從我的數據庫中檢索所有成員數據,然後顯示它在一個列表視圖,它能夠工作。無法刷新列表視圖中的數據
現在我試圖搜索特定的成員,我設法檢索記錄(登錄到logcat),但它並沒有相應地刷新我的列表視圖。
這是我用來檢索搜索記錄的列表視圖代碼。
SimpleAdapter simpleAdapter = new SimpleAdapter(Search.this, productsList, R.layout.list_item, new String[] {TAG_COMPANY},
new int[] { R.id.name});
lv = (ListView) findViewById(R.id.lst_name);
lv.setAdapter(simpleAdapter);
adapter.notifyDataSetChanged( );搜索後試試。 – Raghunandan
「adapter.notifyDataSetChanged();」經過我的搜索,然後仍然使用上面的代碼來檢索它?或.. – Jolene
你有一個編輯文本,你想搜索列表視圖?如果是這種情況,請使用自定義過濾器。下面的答案應該可以幫到你。也看看這個鏈接http://stackoverflow.com/questions/13090046/how-to-implement-search-in-customlistview-based-on-class-item-of-pojo-class-in-a。但是adapter.notifyDataSetChanged();用於刷新列表視圖。 – Raghunandan