How to use layout in the preference ?

I have my own design settings. To implement the necessary, I will need to create a layout , for example, for preferencesCategory .

But after I add this layout , for some reason the title and sumary don't work, although I added a textView at the top and bottom.

How to fix it?

    1 answer 1

    In your layout for TextView, specify @android:id/title ID @android:id/title and @android:id/summary :

     <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@android:id/title" android:layout_width="match_parent" android:layout_height="wrap_content"/> <TextView android:id="@android:id/summary" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> 
    • And I did not do that. I'm in Pref after this is written TextView in the title. Although no, I wrote like this android: id = "@ + id / title". And why is the android ahead? Does this change the standard textView? Is it possible android: id = "@ android: id / title" - Andro
    • one
      @xTIGRx yes, these are different IDs. @ + id / title is the ID in your project, android: id - ID in the Android SDK. You need exactly android - lsillarionov
    • @isllarionov, Why didn't it work like that? pastebin.com/Sd1XJgsz I understand as Pref uses ListVIew. And at the edges there is a certain indent. So I created a new listView and the edges still indent around the edges. - Andro
    • this ListView is not in the PreferenceCategory, but in the PreferenceScreen and it is not so redefined. But specifically this indent seems to be not in it, but in separate elements of the list. I can be mistaken here, I don't remember - lsillarionov