我有一个问题,我无法将参数“context,realmResults,automaticUpdate”传递给super();在扩展RealmBaseAdapter的类的构造函数中.请参阅我的代码和截图,以便为您清楚.
*我的代码:
package com.twitter.i_droidi.notah;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import io.realm.RealmBaseAdapter;
import io.realm.RealmObject;
import io.realm.RealmResults;
public class RealmModelAdapter <T extends RealmObject> extends RealmBaseAdapter<T> {
public RealmModelAdapter(Context context, RealmResults<T> realmResults, boolean automaticUpdate)
{
super(context, realmResults, automaticUpdate);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return null;
}
}
*截图:
*领域版本:1.0.1
* Android Studio版本:2.1.2
解决方法:
在Realm 0.90.0中,您应该使用单独的realm-android-adapters
项目(当前编译’io.realm:android-adapters:1.3.0′).其中RealmBaseAdapter具有以下构造函数签名:
public RealmBaseAdapter(@NonNull Context context, @Nullable OrderedRealmCollection<T> data) {
....
}
所以你会的
super(context, realmResults);
在Realm 2.0.0中,不再需要context参数.
public RealmBaseAdapter(@Nullable OrderedRealmCollection<T> data) {
public RealmRecyclerViewAdapter(@Nullable OrderedRealmCollection<T> data, boolean autoUpdate) { // <-- autoUpdate always recommended to be `true`