我的Android应用程序中有Realm DB,我使用的是realm-recyclerview:
https://github.com/thorbenprimke/realm-recyclerview
现在我正在尝试使用自定义模式对RecyclerView进行排序。
在我考虑之后,我决定对RealmResults进行排序,而不是RecyclerView。
有没有更好的方法来对RecyclerView进行排序?
我的问题是:findAllSorted会像findAll一样自动更新吗? 如果是,是否会自动排序?
答案 0 :(得分:2)
是的,这两种方法都会返回一个RealmResults
对象,该对象会在Realm更改时自动更新。如果更新了领域,结果将自动排序。
RealmResults是实时视图,这意味着如果它在Looper线程上,它将在提交事务后自动更新其查询结果。
请参阅:https://realm.io/docs/java/latest/api/io/realm/RealmQuery.html#findAllSorted-java.lang.String- 请参阅:https://realm.io/docs/java/latest/api/io/realm/RealmResults.html