Я использую FlexboxLayou в своем проекте, но я не могу отменить данные, взятые из базы данных, я хочу, чтобы они были в порядке убывания. Я протестировал:
Collections.reverse (list);
, он работает, не используя FlexboxLayou, но, поскольку у моего проекта разные макеты, лучшим вариантом для сгибания макетов было использование FlexboxLayou. Я попытался в recycleview изменить:
app: stackFromEnd = "true"
app: reverseLayout = "true"
Это не имело никакого эффекта. Я изменил параметры в FlexboxLayou, но некоторые из них выдают ошибку.
FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(context);
flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
flexboxLayoutManager.setJustifyContent(JustifyContent.CENTER);
flexboxLayoutManager.setAlignItems(AlignItems.STRETCH);
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
Если я изменяю FlexWrap.WRAP на FlexWrap.WRAP_REVERSE, адаптер также не работает.
Ошибка после использования Collections.reverse ( list):
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pup, PID: 28144
java.lang.ClassCastException: com.example.pup.Viewholder.Prop.ViewPropU cannot be cast to com.example.pup.Viewholder.Prop.ViewPropS
at com.example.puplica.Adaptadores.AdapatadorProp.onBindViewHolder(AdapatadorProp.java:92)
at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at com.google.android.flexbox.FlexboxLayoutManager.getFlexItemAt(FlexboxLayoutManager.java:456)
at com.google.android.flexbox.FlexboxLayoutManager.getReorderedFlexItemAt(FlexboxLayoutManager.java:474)
at com.google.android.flexbox.FlexboxHelper.calculateFlexLines(FlexboxHelper.java:429)
at com.google.android.flexbox.FlexboxHelper.calculateHorizontalFlexLines(FlexboxHelper.java:249)
at com.google.android.flexbox.FlexboxLayoutManager.updateFlexLines(FlexboxLayoutManager.java:953)
at com.google.android.flexbox.FlexboxLayoutManager.onLayoutChildren(FlexboxLayoutManager.java:729)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:3175)
at android.view.View.layout(View.java:18010)
at android.view.ViewGroup.layout(ViewGroup.java:5911)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2776)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2477)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1544)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7602)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(
Дайте ошибку на адаптере. Я провел большое исследование и не смог получить результат, я попытался инвертировать контент, полученный firebase, но предмет очень сложный, и я не смог этого сделать. должен быть простой способ сделать это.