Pozwolę sobie zacytować siebie za stackoverflow ;)
"Hello I created PreferenceActivity class that loads all preferences from R.xml.preferences and shows them on the list R.layout.preference_list (the simplest layout with the list in it only).
The thing is one of the preference uses specific layout like
<EditTextPreference
android:title="@string/auth_title"
android:summary="@string/auth_summary"
android:key="pass"
android:defaultValue="1"
android:layout="@layout/preference_auth"
android:hint="Enter password"/>
where the key thing here in this layout is
<ImageView
android:id="@+id/iconSelected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingLeft="10dp"
android:layout_alignParentRight="true"
android:src="@drawable/ic_action_no" />
and it describes the icon on the right side. Left side is clickable preference which opens EditText area.
SCREEN: https://s33.postimg.org/ubkp100nz/bbb.png
Now I want to programatically change the source of image that is shown on screen when the app starts (actually when EditText matches to specific string but let's keep simple here as much as it is possible).
EditTextPreference editPref;
ImageView icon;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
setContentView(R.layout.preference_list);
editPref = (EditTextPreference) getPreferenceScreen().findPreference("pass");
icon = (ImageView)getLayoutInflater().inflate(editPref.getLayoutResource(), null).findViewById(R.id.iconSelected);
icon.setImageResource(R.drawable.ic_action_yes);
}
And this code doesn't work. The image seems to be intact. Where is the problem?"