My requirements
Note. I need to support Android API 15 onwards.
In my PreferenceFragment, I dynamically add PreferenceScreen to the PreferenceCategory.
PreferenceScreen as = mgr.createPreferenceScreen(context); as.setTitle(name); myCategory.addPreference(as);
When the Activity settings display these PreferenceScreens, they are only displayed with a heading in a row, see image below. 
I want to customize what is shown on this line. Ideally, I would like to have a headline with the summary below, an icon to the left of the heading / summary, and on some lines an icon to the right. See Layout Image below.

PreferenceScreen.setWidgetLayoutResource (int widgetLayoutResId)
I know that I can use "setWidgetLayoutResource" to add an icon to the right of the line layout (and a resume with "setSummary"), using the following code in my settings.
PreferenceScreen as = mgr.createPreferenceScreen(context); as.setTitle(name); as.setSummary(summary); as.setWidgetLayoutResource(R.layout.as_widget); myCategory.addPreference(as);
where "as_widget.xml"
<?xml version="1.0" encoding="utf-8"?> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_action_favorite"/>
this will create a user interface as shown below. 
This brings me closer to what I would like, but still not quite what I would like (there is no icon at the beginning of the line).
PreferenceScreen.setLayoutResource (int layoutResId)
I believe that if I use this, then I can control the rendering of the entire string. I saw examples of this in stackoverflow, for example
- Setting preferences and changing the attribute in it
- Create a custom layout for settings
In my opinion, the specified layout file should have the following
- its root view with id "@android: id / widget_frame"
- view with id android: id = "@ + android: id / title" (this is where the line specified in PreferenceScreen.setTitle)
- view with id android: id = "@ + android: id / summary" (this is where the line specified in PreferenceScreen.setSummary is placed)
However, when I try to do this, Android Studio emits “@ + android: id / summary” with the error “Unable to resolve the character“ @ + android: id / summary. ”When the application launches my lines, they appear completely empty.
My java
PreferenceScreen as = mgr.createPreferenceScreen(context); as.setTitle(name); as.setSummary(summary); as.setLayoutResource(R.layout.as_row_layout); myCategory.addPreference(as);
And my layout
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/widget_frame" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:paddingRight="?android:attr/scrollbarSize"> <ImageView android:id="@+id/icon1" android:src="@drawable/ic_action_email" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dip" android:layout_marginRight="6dip" android:layout_marginTop="6dip" android:layout_marginBottom="6dip" android:layout_weight="1"> <TextView android:id="@+android:id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" android:ellipsize="marquee" android:fadingEdge="horizontal" /> <TextView android:id="@+android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@android:id/title" android:layout_alignLeft="@android:id/title" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorSecondary" android:maxLines="4" /> </RelativeLayout> <ImageView android:id="@+id/icon2" android:src="@drawable/ic_action_favorite" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout>
Preference Screen Extension
I looked at the extended PreferenceScreen to overwrite its rendering, but it seems that this class has become final, so all the examples on the Internet that do it this way cannot be used.