Display posts in descending posted order

前端 未结 18 1299
南方客
南方客 2020-11-22 11:47

I\'m trying to test out Firebase to allow users to post comments using push. I want to display the data I retrieve with the following;

fbl.child         


        
18条回答
  •  忘掉有多难
    2020-11-22 12:21

    In Android there is a way to actually reverse the data in an Arraylist of objects through the Adapter. In my case I could not use the LayoutManager to reverse the results in descending order since I was using a horizontal Recyclerview to display the data. Setting the following parameters to the recyclerview messed up my UI experience:

    llManager.setReverseLayout(true);
    llManager.setStackFromEnd(true);
    

    The only working way I found around this was through the BindViewHolder method of the RecyclerView adapter:

    @Override
    public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
        final SuperPost superPost = superList.get(getItemCount() - position - 1);
    }
    

    Hope this answer will help all the devs out there who are struggling with this issue in Firebase.

提交回复
热议问题