Preferences XML

PreferencesFragment will use an XML file to construct the user interface for the settings. We need to create a file, named preferences.xml, under the app/src/main/res/xml directory, which will contain the following code:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:key="pref_symbols"
android:summary="Stock Symbols to Follow"
android:title="Symbols" />

<EditTextPreference
android:key="pref_keywords"
android:summary="Twitter keywords to monitor"
android:title="Keywords" />
</PreferenceScreen>

The following element is responsible for displaying a text field whose value will be written to the key named pref_symbols in the SharedPreferences object:

<EditTextPreference
android:key="pref_symbols"
android:summary="Stock Symbols to Follow"
android:title="Symbols" />

Similarly, the block will do the same to write a value to pref_keywords so that the monitored keywords for Twitter can be retrieved later:

<EditTextPreference
android:key="pref_keywords"
android:summary="Twitter keywords to monitor"
android:title="Keywords" />
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.107.152