preference/src/main/java/androidx/preference/Preference.java
public void onBindViewHolder(PreferenceViewHolder holder) {
        holder.itemView.setOnClickListener(mClickListener);
        holder.itemView.setId(mViewId);

        final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
        if (titleView != null) {
            final CharSequence title = getTitle();
            if (!TextUtils.isEmpty(title)) {
                titleView.setText(title);
                titleView.setVisibility(View.VISIBLE);
                if (mHasSingleLineTitleAttr) {
                    titleView.setSingleLine(mSingleLineTitle);
                }
            } else {
                titleView.setVisibility(View.GONE);
            }
        }

        final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
        if (summaryView != null) {
            final CharSequence summary = getSummary();
            if (!TextUtils.isEmpty(summary)) {
                summaryView.setText(summary);
                summaryView.setVisibility(View.VISIBLE);
            } else {
                summaryView.setVisibility(View.GONE);
            }
        }

        final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
        if (imageView != null) {
            if (mIconResId != 0 || mIcon != null) {
                if (mIcon == null) {
                    mIcon = ContextCompat.getDrawable(getContext(), mIconResId);
                }
                if (mIcon != null) {
                    imageView.setImageDrawable(mIcon);
                }
            }
            if (mIcon != null) {
                imageView.setVisibility(View.VISIBLE);
            } else {
                imageView.setVisibility(mIconSpaceReserved ? View.INVISIBLE : View.GONE);
            }
        }

        View imageFrame = holder.findViewById(R.id.icon_frame);
        if (imageFrame == null) {
            imageFrame = holder.findViewById(AndroidResources.ANDROID_R_ICON_FRAME);
        }
        if (imageFrame != null) {
            if (mIcon != null) {
                imageFrame.setVisibility(View.VISIBLE);
            } else {
                imageFrame.setVisibility(mIconSpaceReserved ? View.INVISIBLE : View.GONE);
            }
        }

        if (mShouldDisableView) {
            setEnabledStateOnViews(holder.itemView, isEnabled());
        } else {
            setEnabledStateOnViews(holder.itemView, true);
        }

        final boolean selectable = isSelectable();
        holder.itemView.setFocusable(selectable);
        holder.itemView.setClickable(selectable);

        holder.setDividerAllowedAbove(mAllowDividerAbove);
        holder.setDividerAllowedBelow(mAllowDividerBelow);
    }
/**
     * Binds the created View to the data for this Preference.
     * <p>
     * This is a good place to grab references to custom Views in the layout and
     * set properties on them.
     * <p>
     * Make sure to call through to the superclass's implementation.
     *
     * @param holder The ViewHolder that provides references to the views to fill in. These views
     *               will be recycled, so you should not hold a reference to them after this method
     *               returns.
     */
Binds the created View to the data for this Preference.

This is a good place to grab references to custom Views in the layout and
set properties on them.

Make sure to call through to the superclass's implementation.

@param holder The ViewHolder that provides references to the views to fill in. These views
will be recycled, so you should not hold a reference to them after this method
returns.
Binds the created View to the data for this Preference . This is a good place to grab references to custom Views in the layout and set properties on them . Make sure to call through to the superclass ' s implementation . @param holder The ViewHolder that provides references to the views to fill in . These views will be recycled so you should not hold a reference to them after this method returns .
public void onBindViewHolder(PreferenceViewHolder holder) {
        holder.itemView.setOnClickListener(mClickListener);
        holder.itemView.setId(mViewId);
        final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
        if (titleView != null) {
            final CharSequence title = getTitle();
            if (!TextUtils.isEmpty(title)) {
                titleView.setText(title);
                titleView.setVisibility(View.VISIBLE);
                if (mHasSingleLineTitleAttr) {
                    titleView.setSingleLine(mSingleLineTitle);
                }
            } else {
                titleView.setVisibility(View.GONE);
            }
        }
        final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
        if (summaryView != null) {
            final CharSequence summary = getSummary();
            if (!TextUtils.isEmpty(summary)) {
                summaryView.setText(summary);
                summaryView.setVisibility(View.VISIBLE);
            } else {
                summaryView.setVisibility(View.GONE);
            }
        }
        final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
        if (imageView != null) {
            if (mIconResId != 0 || mIcon != null) {
                if (mIcon == null) {
                    mIcon = ContextCompat.getDrawable(getContext(), mIconResId);
                }
                if (mIcon != null) {
                    imageView.setImageDrawable(mIcon);
                }
            }
            if (mIcon != null) {
                imageView.setVisibility(View.VISIBLE);
            } else {
                imageView.setVisibility(mIconSpaceReserved ? View.INVISIBLE : View.GONE);
            }
        }
        View imageFrame = holder.findViewById(R.id.icon_frame);
        if (imageFrame == null) {
            imageFrame = holder.findViewById(AndroidResources.ANDROID_R_ICON_FRAME);
        }
        if (imageFrame != null) {
            if (mIcon != null) {
                imageFrame.setVisibility(View.VISIBLE);
            } else {
                imageFrame.setVisibility(mIconSpaceReserved ? View.INVISIBLE : View.GONE);
            }
        }
        if (mShouldDisableView) {
            setEnabledStateOnViews(holder.itemView, isEnabled());
        } else {
            setEnabledStateOnViews(holder.itemView, true);
        }
        final boolean selectable = isSelectable();
        holder.itemView.setFocusable(selectable);
        holder.itemView.setClickable(selectable);
        holder.setDividerAllowedAbove(mAllowDividerAbove);
        holder.setDividerAllowedBelow(mAllowDividerBelow);
    }
public void onBindViewHolder ( PreferenceViewHolder holder ) { holder . itemView . setOnClickListener ( mClickListener ) ; holder . itemView . setId ( mViewId ) ; final TextView titleView = ( TextView ) holder . findViewById ( android . R . id . title ) ; if ( titleView != null ) { final CharSequence title = getTitle ( ) ; if ( ! TextUtils . isEmpty ( title ) ) { titleView . setText ( title ) ; titleView . setVisibility ( View . VISIBLE ) ; if ( mHasSingleLineTitleAttr ) { titleView . setSingleLine ( mSingleLineTitle ) ; } } else { titleView . setVisibility ( View . GONE ) ; } } final TextView summaryView = ( TextView ) holder . findViewById ( android . R . id . summary ) ; if ( summaryView != null ) { final CharSequence summary = getSummary ( ) ; if ( ! TextUtils . isEmpty ( summary ) ) { summaryView . setText ( summary ) ; summaryView . setVisibility ( View . VISIBLE ) ; } else { summaryView . setVisibility ( View . GONE ) ; } } final ImageView imageView = ( ImageView ) holder . findViewById ( android . R . id . icon ) ; if ( imageView != null ) { if ( mIconResId != 0 || mIcon != null ) { if ( mIcon == null ) { mIcon = ContextCompat . getDrawable ( getContext ( ) , mIconResId ) ; } if ( mIcon != null ) { imageView . setImageDrawable ( mIcon ) ; } } if ( mIcon != null ) { imageView . setVisibility ( View . VISIBLE ) ; } else { imageView . setVisibility ( mIconSpaceReserved ? View . INVISIBLE : View . GONE ) ; } } View imageFrame = holder . findViewById ( R . id . icon_frame ) ; if ( imageFrame == null ) { imageFrame = holder . findViewById ( AndroidResources . ANDROID_R_ICON_FRAME ) ; } if ( imageFrame != null ) { if ( mIcon != null ) { imageFrame . setVisibility ( View . VISIBLE ) ; } else { imageFrame . setVisibility ( mIconSpaceReserved ? View . INVISIBLE : View . GONE ) ; } } if ( mShouldDisableView ) { setEnabledStateOnViews ( holder . itemView , isEnabled ( ) ) ; } else { setEnabledStateOnViews ( holder . itemView , true ) ; } final boolean selectable = isSelectable ( ) ; holder . itemView . setFocusable ( selectable ) ; holder . itemView . setClickable ( selectable ) ; holder . setDividerAllowedAbove ( mAllowDividerAbove ) ; holder . setDividerAllowedBelow ( mAllowDividerBelow ) ; }
Binds the created View to the data for this Preference.
Binds the created View to the data for this Preference .