Android preference screen without XML

I want to create a settings screen without writing an XML layout file. I would like to save the settings in a SQLite database. Is it possible?

+4
source share
1 answer

You can simply create a hierarchy of preferences (possibly in onCreate() for PreferenceFragment ) with:

 PreferenceScreen screen = new PreferenceScreen(); 

and add preference items to screen using addPreference . In a PreferenceFragment (or PreferenceActivity if you are not using fragments), just call setPreferenceScreen with the hierarchy after creating it.

+1
source

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


All Articles