diff --git a/demo/src/main/java/com/example/prefsplus/PrefsPlusActivity.java b/demo/src/main/java/com/example/prefsplus/PrefsPlusActivity.java
index 80930ec..ca63a27 100644
--- a/demo/src/main/java/com/example/prefsplus/PrefsPlusActivity.java
+++ b/demo/src/main/java/com/example/prefsplus/PrefsPlusActivity.java
@@ -3,6 +3,7 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
+import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
@@ -59,11 +60,7 @@ public static class PrefsPlusFragment extends Fragment {
private TextView floatTextView;
private TextView integerListTextView;
private TextView textTextView;
-
- private int intValue;
- private float floatValue;
- private int intListValue;
- private String textValue;
+ private TextView colorTextView;
private SharedPreferences prefs;
private Resources res;
@@ -76,6 +73,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
floatTextView = (TextView) view.findViewById(R.id.float_value);
integerListTextView = (TextView) view.findViewById(R.id.integer_list_value);
textTextView = (TextView) view.findViewById(R.id.text_value);
+ colorTextView=(TextView) view.findViewById(R.id.tv_color_value);
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
res = getResources();
return view;
@@ -84,19 +82,21 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void onResume() {
super.onResume();
- intValue = prefs.getInt(res.getString(R.string.integer_key),
+ int intValue = prefs.getInt(res.getString(R.string.integer_key),
res.getInteger(R.integer.integer_default_value));
- floatValue = prefs.getFloat(res.getString(R.string.float_key),
+ float floatValue = prefs.getFloat(res.getString(R.string.float_key),
res.getInteger(R.integer.integer_default_value));
- intListValue = prefs.getInt(res.getString(R.string.integer_list_key),
+ int intListValue = prefs.getInt(res.getString(R.string.integer_list_key),
res.getInteger(R.integer.integer_default_value));
- textValue = prefs.getString(res.getString(R.string.text_key),
+ String textValue = prefs.getString(res.getString(R.string.text_key),
res.getString(R.string.text_default_value));
+ int colorValue = prefs.getInt(res.getString(R.string.color_key), Color.RED);
integerTextView.setText(Integer.toString(intValue));
floatTextView.setText(Float.toString(floatValue));
integerListTextView.setText(Integer.toString(intListValue));
textTextView.setText(textValue);
+ colorTextView.setBackgroundColor(colorValue);
}
}
}
diff --git a/demo/src/main/res/layout/fragment_prefs_plus.xml b/demo/src/main/res/layout/fragment_prefs_plus.xml
index 119bcb9..1ded419 100644
--- a/demo/src/main/res/layout/fragment_prefs_plus.xml
+++ b/demo/src/main/res/layout/fragment_prefs_plus.xml
@@ -73,6 +73,14 @@
android:layout_marginBottom="16dp"
android:textSize="16sp" />
+
+
+
+
+
diff --git a/demo/src/main/res/values/colors.xml b/demo/src/main/res/values/colors.xml
new file mode 100644
index 0000000..ee0fded
--- /dev/null
+++ b/demo/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ #F44336
+
+
+
+
+
diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml
index 5561ac1..8ff78a6 100644
--- a/demo/src/main/res/values/strings.xml
+++ b/demo/src/main/res/values/strings.xml
@@ -19,4 +19,6 @@
Enter a string
Update current values via Settings
+ color_key
+
diff --git a/demo/src/main/res/xml/preferencesx.xml b/demo/src/main/res/xml/preferencesx.xml
index 0083834..25d4a47 100644
--- a/demo/src/main/res/xml/preferencesx.xml
+++ b/demo/src/main/res/xml/preferencesx.xml
@@ -29,19 +29,12 @@
android:dialogTitle="@string/text_dialog_title"
android:defaultValue="@string/text_default_value" />
-
-
+ android:key="@string/color_key"
+ android:title="@string/color_key"
+ android:summary="Select text background color"
+ app:colorShape="circle"
+ android:defaultValue="@color/DEFAULT_TV_BACKGROUND_COLOR"/>