簡體   English   中英

ListView 項目不會從中刪除

[英]ListView items doesn't get removed from it

當我更改 ListViewAdapter 時,我的項目不會從 ListView 中清除,並且我有一些空白條目。

她是我的代碼:

HashMap<String, HashMap<String, String>> arrivals = new HashMap<>();
dataSnapshot.getChildren().forEach(dataSnapshot1 -> {
    if (dataSnapshot1.child("provenance").getValue().toString() != "") {
        HashMap<String, String> map = new HashMap<>();
        map.put("prov", Objects.requireNonNull(dataSnapshot1.child("provenance").getValue()).toString());
        map.put("dest", "");
        arrivals.put(dataSnapshot1.getKey(), map);
    }
});
    TrainAdapter adapter = new TrainAdapter(arrivals);
    // trains is my ListView
    trains.setAdapter(adapter);

還有應用截圖: 截屏

您必須從列表和適配器中刪除您的項目(使用新數據集更新您的適配器),然后調用 notifyDataSetChange。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM