Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Last active June 26, 2017 06:06
Show Gist options
  • Save tzmartin/61ca361070409fdb8153 to your computer and use it in GitHub Desktop.
Save tzmartin/61ca361070409fdb8153 to your computer and use it in GitHub Desktop.
The Android equivalent to Settings.bundle is called Preferences. The preferences configuration files must be created in the project folders, platform/android/res/xml/preferences.xml and platform/android/res/values/array/array.xml.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="listNames">
<item>5 Minutes</item>
<item>10 Minutes</item>
<item>15 Minutes</item>
<item>30 Minutes</item>
<item>60 Minutes</item>
</string-array>
<string-array name="listValues">
<item>5</item>
<item>10</item>
<item>15</item>
<item>30</item>
<item>60</item>
</string-array>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="Preferences">
<PreferenceScreen
android:title="Misc. Preferences"
android:summary="Click to see more options">
<EditTextPreference
android:title="Edit Text Preference"
android:summary="You may enter a string"
android:defaultValue=""
android:key="editText" />
</PreferenceScreen>
<PreferenceCategory android:title="Category One">
<CheckBoxPreference
android:title="CheckBox Preference"
android:defaultValue="false"
android:summary="You may enter a boolean"
android:key="checkbox" />
<RingtonePreference
android:title="Ringtone Preference"
android:summary="You may pick a ringtone"
android:defaultValue=""
android:key="ringtone" />
</PreferenceCategory>
<PreferenceCategory android:title="Category Two">
<ListPreference
android:title="List Preference"
android:summary="You may chose from multiple choices"
android:key="list"
android:entries="@array/listNames"
android:entryValues="@array/listValues"
/>
</PreferenceCategory>
</PreferenceScreen>
@tzmartin
Copy link
Author

Refer to the Android docs for available setting properties: http://developer.android.com/guide/topics/ui/settings.html.

Once defined, you can use invoke the Settings window from your app using the openPreferences function: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Android-method-openPreferences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment