Android Preferences

3,113 views

Published on

Android Preferences
Rajab Davudov

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,113
On SlideShare
0
From Embeds
0
Number of Embeds
2,155
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Android Preferences

  1. 1. Rajab Davudov
  2. 2. Preferences are Important• Preferences are an important part of an Android application. It is important to let the users have the choice to modify and personalize their application depending on their needs.
  3. 3. Preferences are Important
  4. 4. How To• res/xml/preferences.xml• an Activity extends PreferenceActivity
  5. 5. Preference Types• The CheckBoxPreference is a simple checkbox, that can return true or false.• The ListPreference, which shows a radioGroup where only 1 item can be selected a time.• The EditTextPreference shows a dialog with an editText view which returns a String.
  6. 6. Preference Types
  7. 7. Preference Types• The RingtonePreference shows a radioGroup that shows the ringtones.• The Preference is a custom preference.• The PreferenceScreen is a screen with preferences. When you have a PreferenceScreen inside an other PreferenceScreen, it simply opens a new screen with other preferences.
  8. 8. Preference Types
  9. 9. CheckBoxPreference<CheckBoxPreference android:title="Checkbox Preference" android:defaultValue="false" android:summary="This preference can be true or false" android:key="checkboxPref" />
  10. 10. ListPreference<ListPreference android:title="List Preference" android:summary="This preference allows to select an item in a array" android:key="listPref" android:defaultValue="digiGreen" android:entries="@array/listArray" android:entryValues="@array/listValues" />
  11. 11. Use PreferencesSharedPreferences sp =PreferenceManager.getDefaultSharedPreferences(this);boolean checked = sp.getBoolean("checkBox", true) ;String s = sp.getString("radioButton", "default") ;
  12. 12. Think, Design, Code !!!
  13. 13. Rajab Davudov Senior Developer at Azerfon radjab@gmail.comhttps://play.google.com/store/apps/developer?id=RADJABhttp://gplus.to/radjabhttp://www.fb.me/rajab.davudovhttp://www.linkedin.com/in/radjab

×