How to use textview in Android PreferenceScreen?

I would like to use textview in PreferenceScreen, this is a longer text that explains some specific settings. If I use the summary or title attribute in some versions, it is formatted strangely, does not display correctly, etc. (The text is quite long).

Therefore, I believe that it is best to use textview, is it possible to create a custom settings item?

+4
source share
3 answers

You can assign a layout resource to your preferences in your XML file using the android:layout="@layout/your_pref_layout" tag android:layout="@layout/your_pref_layout" .

Remember to use the correct identifiers in your layout (android: id = "@ + android: id / title", android: id = "@ + android: id / summary") to assign views to be used as headers / summary views .

For more information, see for example: Creating a Custom Layout for Settings

or this: How to add a button to the preferences screen

+6
source

Use this:

 <Preference android:selectable="false" android:enabled="true" android:key="example_key" android:title="example_title" android:summary="anything_you_want" /> 

The attributes selected will determine the click action of the Preferences.

+18
source

Yes. You can create a layout and use this layout file to inflate as a settings screen. Here you can see an example.

custom EditTextPreference: cannot get TextView by id

0
source

Source: https://habr.com/ru/post/1497976/


All Articles