由于 RealmObject 只能在创建它们的线程中访问,因此不可能将其与 ListAdapter 一起使用,因为使用了 AsyncListDiffer 在这种情况下你会得到这个异常
Realm access from incorrect thread. Realm objects can only be accessed on the thread they were created.
有替代方案吗?我的第一个建议是将 RealmObject 映射到代 TableView 数据的 Pojo 中,但由于列表中有很多更改,它会减慢 UI 线程。
最佳答案
使用自 0.87.0
起可用的 Realm.copyFromRealm()
来复制已持久化的 RealmObject。
关于android - 将 RealmObject 与 Recyclerview ListAdapter 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55283648/