I have a recyclerview populated by a Realm db, with an option to duplicate an item in the list. The kicker here is that the newly added duplicate may not always appear directly below the chosen item. In normal circumstances one would use
int position = mList.indexOf(duplicate);
mAdapter.notifyItemInserted(position);
It seems indexOf, from the AbstractList class, is not supported in Realm,
java.lang.NoSuchMethodError: indexOf is not supported on RealmResults at io.realm.RealmResults.indexOf(RealmResults.java:183)
What would be another solution? ( WITHOUT using mAdapter.notifyDataSetChanged() )
Can't you use a classic For-loop and return the index if the Item matches? ie
for (int i = 0; i < mList.size(); i++){
if (mList.get(i).equals(duplicate)){
return i;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.