How to delete duplicated items in Listview filled with objects from real-time database

后端 未结 2 1617
庸人自扰
庸人自扰 2021-01-26 03:20

I am fetching data from my database based on the userId then I insert the data in a listview and show it through a dialog.

The behavior I was w

2条回答
  •  悲&欢浪女
    2021-01-26 04:04

    try this

    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
        if (dataSnapshot.exists()) {
            SwapDetails swapDetails = dataSnapshot.getValue(SwapDetails.class);
            if (swapDetails.getSwapperID().equals(fromID)) {
                swapBodyList.add(swapDetails);
                shiftProfileAdapter.notifyItemInserted(swapBodyList.length - 1);
            }
        }
    }
    

提交回复
热议问题