'How to get references to views in custom PreferenceScreen

I have a custom PreferenceScreen in preferences.xml

    <PreferenceScreen
            android:key="userImage"
            android:layout="@layout/user_profile" />

and inside user_profile.xml layout, I have:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    android:layout_height="wrap_content">


    <ImageView
        android:id="@+id/profile_pic"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:src="@drawable/ic_default_img" />


    <TextView
        android:id="@+id/edit_profile_pic"
        android:layout_width="wrap_content"
        android:layout_margin="10dp"
        android:layout_height="wrap_content"
        android:text="Change Photo" />


    </LinearLayout>

How can I get references to the ImageView and the TextView from PreferenceActivity?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source