英文:
SetHasFixedSizetrue shows error How to solve it
问题
我有一个带有Firebase后端的RecyclerView。我希望在我的视图中将最新的项目显示在顶部。我只是在我的LayoutManager中使用了setStackFromEnd(true);但是它显示错误,就像这样:
![查看图片][1]
[1]: https://i.stack.imgur.com/P56YX.png
我的最低SDK版本是16
我使用了<androidx.recyclerview.widget.RecyclerView
这是我的Java代码:
MCC = FirebaseDatabase.getInstance().getReference().child("Troll");
recyclerView = (RecyclerView) findViewById(R.id.TrollID_recyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
LoadData(categoryId);
英文:
I have a recyclerview with firebase backend. I want to show latest item on top in my view. I just use setStackFromEnd(true); in my layoutmanager but its show error jutst like this
My minimum SDK Version is 16
and I used to <androidx.recyclerview.widget.RecyclerView
and this is my java code
MCC=FirebaseDatabase.getInstance().getReference().child("Troll");
recyclerView = (RecyclerView) findViewById(R.id.TrollID_recyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
LoadData(categoryId);
答案1
得分: 1
你应该首先将最新的项目存储在recycleadapterList中,然后再将其他项目添加到列表中。因为recycleadapter会根据列表项的位置显示项目。
英文:
you should store latest item first in recycleadapterList then your other items add to list.
because recycleadapter show items like list item position
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论