我正在使用FastAdapter
因为它很有趣并且使我无法编写适配器类。这里是一个类:在扩展AbstractItem的同时实现RealmModel
public class ProductsModel extends AbstractItem<ProductsModel, ProductsModel.ViewHolder> {
但最近我想用Realm
而不是SQLite
。所以我想这样做:
public class ProductsModel extends AbstractItem<ProductsModel, ProductsModel.ViewHolder> implements RealmModel {
而且任何交易之前,我这样做:
RealmResults<ProductsModel> productsModels = realm.where(ProductsModel.class).findAll(); // <- this line is generating the exception
if(productsModels.size() == 0){ //no product is saved, download now
}
但得到这个异常:
java.lang.IllegalArgumentException: AbstractItem is not part of the schema for this Realm
请告诉我如何使用领域与FastAdapter。
我仍然使用领域和FastAdapter,但你'ProductsModel'上方的代码不是Realm中的模型,它是代表适配器中项目的**项目**。所以它不能'实现RealmModel'。这只是项目,你需要遵循fastadapter的例子来做到这一点。 –
谢谢,你能分享任何示例/教程吗?我没有[this](https://github.com/mikepenz/FastAdapter/tree/develop/library-extensions-realm) –
你可以从https://github.com/mikepenz/FastAdapter/tree/得到它开发/应用程序。只需全部并建立它。 –