简单的ViewHolder可以如下所示。
视图元素是否应该保存在WeakRefererence中以避免使用View查看此ViewHolder的强循环引用?
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextContent;
public ImageView mImageView;
//or ?
//WeakReference<TextView> mTextContentRef = null;
//WeakReference<ImageView> mImageViewRef = null;
/**
* Constructor
* @param v The container view which holds the elements from the row item xml
*/
public ViewHolder(View v) {
super(v);
mTextContent = (Button) v.findViewById(R.id.text);
mImageView = (ImageView) v.findViewById(R.id.image);
}
}