应该在RecyclerView.VieweHolder?</view>中使用WeakReference <view>

时间:2015-01-13 13:15:34

标签: android weak-references android-viewholder recycler-adapter

简单的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);
    }
}

0 个答案:

没有答案