I have studied preference activity but I don't understand it. Can anybody tell me what is the use of preference activity? How does it differ from activity?
Thanks
Navigate to the app > res > xml > preferences.
To inflate from XML, use the addPreferencesFromResource(int) . The root element should be a PreferenceScreen . Subsequent elements can point to actual Preference subclasses. As mentioned above, subsequent PreferenceScreen in the hierarchy will result in the screen break.
A Preference that provides checkbox widget functionality. This preference will store a boolean into the SharedPreferences.
It's still possible to customise the appearance of a Preference item though. In your XML you have to declare the root element as android:id="@android:id/widget_frame , and then declare TextView as android:title and android:summary . You can then declare other elements you want to appear in the layout.
PreferencesActivity is a way to easily create preference screens such as those in Android itself, just look under Settings
. These can be used inside applications to easily save preferences to SharedPreferences and then easily access these from within your app.
See this page for more information on PreferenceActivity.
An example of a PreferenceActivity showing some preferences:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With