Advertisement
Guest User

Untitled

a guest
May 6th, 2012
1,313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. Android: How can make custom PreferenceScreen?
  2. PreferenceScreen screen = createPreferenceHierarchy();
  3.  
  4. setPreferenceScreen(screen);
  5.  
  6. Preferences.java
  7.  
  8. import android.content.Intent;
  9. import android.os.Bundle;
  10. import android.preference.PreferenceActivity;
  11. import android.view.View;
  12. import android.widget.Button;
  13.  
  14. public class Preferences extends PreferenceActivity {
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.preference_holder);
  19. addPreferencesFromResource(R.layout.preferences);
  20.  
  21. Button backButton = (Button) findViewById(R.id.backPrefBurron);
  22. backButton.setOnClickListener(new View.OnClickListener() {
  23. public void onClick(View view) {
  24. Intent myIntent = new Intent(getBaseContext(),
  25. BTFirstTab.class);
  26. startActivity(myIntent);
  27. }
  28. });
  29.  
  30. }
  31. }
  32.  
  33. <?xml version="1.0" encoding="utf-8"?>
  34. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  35. android:layout_width="fill_parent" android:layout_height="fill_parent"
  36. android:orientation="vertical">
  37. <LinearLayout android:orientation="horizontal"
  38. android:background="@color/bto_dark_green" android:layout_width="fill_parent"
  39. android:gravity="center_vertical" android:layout_height="wrap_content"
  40. android:paddingTop="4dip">
  41. <Button android:id="@+id/backPrefBurron" android:layout_width="wrap_content"
  42. android:layout_height="wrap_content" android:text="Home" />
  43.  
  44. <TextView android:id="@+id/backText" android:textSize="14dip"
  45. android:paddingLeft="5dip" android:textColor="@color/white"
  46. android:textStyle="bold" android:layout_width="wrap_content"
  47. android:layout_height="wrap_content" android:layout_weight="1.0"
  48. android:text="Preferences: Home will update all areas of the app" />
  49. </LinearLayout>
  50. <ListView android:id="@android:id/list" android:layout_width="fill_parent"
  51. android:layout_height="fill_parent" />
  52. </LinearLayout>
  53.  
  54. <?xml version="1.0" encoding="utf-8"?>
  55. <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
  56. android:background="@color/bto_light_green">
  57.  
  58. <EditTextPreference android:title="Your BTO UserName"
  59. android:key="username" android:summary="Please provide your username"> </EditTextPreference>
  60. <EditTextPreference android:title="Your BTO Password"
  61. android:password="true" android:key="password" android:summary="Please provide your password (case sensitive)"></EditTextPreference>
  62. <ListPreference android:title="Species order"
  63. android:summary="This preference selects the species order for some viewing sightings activities"
  64. android:key="speciesorder" android:defaultValue="date_order" android:entries="@array/listArray"
  65. android:entryValues="@array/listValues"></ListPreference>
  66. </PreferenceScreen>
  67.  
  68. <?xml version="1.0" encoding="utf-8"?>
  69. <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
  70. <PreferenceCategory
  71. android:title="First Category"
  72. android:key="first_category">
  73.  
  74. <CheckBoxPreference
  75. android:key="perform_updates"
  76. android:summary="Enable or disable data updates"
  77. android:title="Enable updates"
  78. android:defaultValue="true"
  79. />
  80.  
  81. <ListPreference
  82. android:key="updates_interval"
  83. android:title="Updates interval"
  84. android:summary="Define how often updates will be performed"
  85. android:defaultValue="1000"
  86. android:entries="@array/updateInterval"
  87. android:entryValues="@array/updateIntervalValues"
  88. android:dependency="perform_updates"
  89. />
  90.  
  91. </PreferenceCategory>
  92.  
  93. <PreferenceCategory
  94. android:title="Second Category"
  95. android:key="second_category">
  96.  
  97. <EditTextPreference
  98. android:key="welcome_message"
  99. android:title="Welcome Message"
  100. android:summary="Define the Welcome message to be shown"
  101. android:dialogTitle="Welcome Message"
  102. android:dialogMessage="Provide a message"
  103. android:defaultValue="Default welcome message" />
  104.  
  105. </PreferenceCategory>
  106.  
  107. </PreferenceScreen>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement