我有代碼:獲取內部onCreateViewholder當前位置recyclerview的Android
@Override
public CustomRatingHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.custom_rating_lyt, null);
CustomRatingReviews ratingObj = (null != mRatingLst && position < mRatingLst.size()) ?
mRatingLst.get(position) : null;
CustomRatingHolder viewHolder = new CustomRatingHolder(mAdapContext, ratingObj, view);
position++;
return viewHolder;
}
我想回收適配器的onCreateViewHolder內的當前位置。任何人都可以幫我解決這個問題。提前致謝。
getAdapterPosition是RecyclerView.ViewHolder抽象類而不是RecyclerView.Adapter類的方法。 –