本文介绍了firebaseArray降序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用firebaseArray,是否可以通过指定的子键进行排序:
()?

  var fireRef =新的Firebase(https://dinosaur-facts.firebaseio.com/dinosaurs); 
var query = fireRef.orderByChild(echo)。limitToFirst(25);
var todos = $ firebaseArray(query);

但是,默认情况下,Firebase会按升序顺序检索键。

有没有什么办法可以从firebaseArray中直接从降序获得结果?例如,他们有没有像.reverse()或.orderBy(desc,...)?

解决方案

直接回答原始问题,但是对于任何使用FirebaseUI Java / Android的人员,如果使用RecyclerView,则可以反向订购回收站视图,而不是在Firebase上使用查询:



示例:
$ b $ pre $ LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)

(确保在将布局管理器添加到回收者视图也)

Github问题:


Using firebaseArray, is it possible to order by a specified child key:(https://www.firebase.com/docs/web/guide/retrieving-data.html#section-queries)?

var fireRef = new Firebase(https://dinosaur-facts.firebaseio.com/dinosaurs);
var query = fireRef.orderByChild("echo").limitToFirst(25);
var todos = $firebaseArray(query);

However, by default, Firebase retrieves the keys in ascending order.

Is there any way to get results in the descending order directly from firebaseArray? For example, do they have anything like .reverse() or .orderBy(desc, ...)?

解决方案

This doesn't directly answer the original question, but for anyone using FirebaseUI Java/Android, with a RecyclerView, it's possible to order the recycler view in reverse, rather than using a query on firebase:

Example:

LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)

(Ensuring you set both before adding the layout manager to the recycler view also)

Github issue: https://github.com/firebase/FirebaseUI-Android/issues/90#issuecomment-230643303

这篇关于firebaseArray降序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 05:03