Comments (4)
You should be able to load the value from shared preferences as an integer (which is how android represents colours), e.g...
https://stackoverflow.com/a/17916954
Use the same key that you specified in your preference screen xml.
from hsv-alpha-color-picker-android.
Hi, sorry do not understand, here how it looks from my side.
Preference screen, all good, can go in and pick color. After exit it is saved somewhere, I guess shared preferences. Because when i come back in app second time, newly picked color is there.
PreferenceScreen start
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<com.rarepebble.colorpicker.ColorPreference
android:key="listColor"
android:title="@string/listColor"
android:defaultValue="#abcfb4"
/>
PreferenceScreen end
Get color:
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("listColor", 0);
int listColor = sharedPreferences.getInt("listColor", 0);
and I never get color.
Where is the problem?
from hsv-alpha-color-picker-android.
You should probably use getDefaultSharedpreferences(). "listColor" is probably not the name of your preferences file.
from hsv-alpha-color-picker-android.
Thanks Martin, Your color library is perfect.
Worked as You said:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
int listColor = prefs.getInt("listColor", 0);
Thankyou very much.
from hsv-alpha-color-picker-android.
Related Issues (20)
- String cannot be cast to Integer (incorrect library usage?) HOT 2
- getColor() doesn't always return latest value HOT 2
- After hex value is deleted, color changes to transparent even though colorpicker_showAlpha is set to false HOT 2
- ColorPreference: read from disk on UI thead HOT 2
- When creating ColorPreference programmatically defaultValue not works HOT 2
- Impossible to use the library on android P HOT 1
- defaultValue does not work anymore on older devices HOT 4
- public constructor for ObservableColor HOT 2
- Setting color with low brightness leads to different colors HOT 3
- Default button sets a wrong color 888888 HOT 9
- java.lang.ClassCastException: com.rarepebble.colorpicker.ColorPreference cannot be cast to androidx.preference.Preference HOT 3
- modification of the demo app
- Migrate to AndroidX HOT 1
- Dark Theme how to implement HOT 3
- Non-SharedPreference based projects HOT 1
- Question: Use of Enter key to confirm HEX colour change
- jcenter() HOT 12
- Colors not displaying properly with darkmode HOT 2
- Add support for PreferenceDataStore HOT 2
- Infrequent Crashing with Resources$NotFoundException HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hsv-alpha-color-picker-android.