【问题标题】:How to add newly added data from firebase to the top of the recyclerview and not at the bottom [duplicate]如何将新添加的数据从firebase添加到recyclerview的顶部而不是底部[重复]
【发布时间】:2018-03-27 06:38:10
【问题描述】:

我正在Firebase 上制作 Android 应用程序,我希望在顶部看到与 Facebook 等相同的新数据。

当用户上传新数据时如何在我的应用中显示数据请告诉我如何做到这一点

//layout recycler
recyler_view=(RecyclerView)findViewById(R.id.recyclerView);
recyler_view.setHasFixedSize(true);
layoutManager=new LinearLayoutManager(this);
recyler_view.setLayoutManager(layoutManager);

#xml#


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>

</LinearLayout>

【问题讨论】:

  • thnku 太好了 .. 它的 awsm 和简单的@SantanuSur
  • 我的新数据显示在顶部,但我有一个设计问题请参阅我的问题的图像我的底部数据设计不同@SantanuSur

标签: android firebase user-interface android-recyclerview recyclerview-layout


【解决方案1】:

尝试将此属性应用到您的 layoutManager

layoutManager.setStackFromEnd(true); // it will reverse the stack (bottom to top)
layoutManager.setReverseLayout(true); // When set to true, If RecyclerView is LTR, than it will layout from RTL
recyler_view.setLayoutManager(layoutManager);

【讨论】:

  • 这工作 awsm @Deep
  • 但是为什么我的底部信息设计错误来自所有顶级信息
  • 成功了,请接受答案!是的,无法获得您的第二条评论
  • 为您遇到问题的设计添加屏幕截图。
猜你喜欢
  • 2016-10-27
  • 1970-01-01
  • 1970-01-01
  • 2012-05-25
  • 2016-12-15
  • 2013-04-25
  • 1970-01-01
  • 2017-08-12
  • 1970-01-01
相关资源
最近更新 更多