Adding a header to a PreferenceActivity

后端 未结 2 1392
[愿得一人]
[愿得一人] 2021-01-11 16:19

So I have found that android PreferenceScreen is not very style-friendly. Is there a semi-simple way to just add a header (say an image) to the preferencescreen before the

2条回答
  •  走了就别回头了
    2021-01-11 17:14

    In my app I do exactly what you are requesting like this:

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
        setContentView(R.layout.preferences_layout);
    }
    

    and in the preferences_layout.xml file:

    
    
    
    
    
    
    

    Notice the android:id set on the ListView in the xml Now you have control over the layout of the preferences screen and use the default style for the preferences as long as you use built-in preferences.

提交回复
热议问题