Show extra info for Preference screens when CheckboxPreference summary field is not enough long?

前端 未结 3 1079
花落未央
花落未央 2021-02-11 07:35

I have a screen where you can enable/disable modules for my Android application.

For this I use a CheckboxPreference screen. This is all good, but the summary field gets

3条回答
  •  名媛妹妹
    2021-02-11 08:14

    I found an alternative solution that fits better in my case since I needed longer summaries for different types of preferences, not only CheckboxPreferences.

    • I copied the file data/res/layout/preference.xml from the SDK to res/layout/preference_long_summary.xml in my app. (I took the one from API level 7, since it seems to work also for higher levels)
    • removed the android:maxLines attribute from the @+android:id/summary TextView
    • referenced this layout from my preferences for the preferences where I needed longer summary with android:layout="@layout/preference_long_summary"

提交回复
热议问题