Comments (8)
this code:
mysharedPreferences.getInt("mechanism_color",R.integer.COLOR_Fuchsia);
even not part of ColorPickerPreference, it's part of android.content.SharedPreferences.
The problem is, when you don't have any preferences saved in your app, this code should return default value from second param
from android-colorpickerpreference.
Thanks, yes. I know its my code, so entirely my problem.
However, I am using the ColorPickerPreference in exactly the same way as I am using ListPreference, CheckBoxPreference etc. These all return the correct values (ie the correct DefaultValue) whether I have used the Preference or not. For my ColorPicker Preference, the correct value is not returned until after I have used the Preference the first time. The incorrect value has Red = 5, Blue = 0, Green =1 which is very nearly black, which is a very bad default color. It does not return the default value in my settings.xml, set up as follows:
<com.test.ColorPickerPreference
android:key="mechanism_color" android:title="Mechanism Color"
android:summary="Your preferred mechanism color" android:defaultValue="@integer/COLOR_Fuchsia" />
With COLOR_Fuchsia = 0xffff00ff in my values/integer
Whilst acknowledging that the problem must be mine, I am using the ColorPickerPreference in exactly the same way as all my other Preferences, but it does function differently.
Any suggestions would be welcome.
Peter Webb
from android-colorpickerpreference.
ListPreference, stores value as String & CheckBoxPreference stores value as Boolean, so u call mysharedPreferences.getString & mysharedPreferences.getBoolean respectively. Maybe it's some issue with SharedPreferences.getInt..
but shouldn't, it's one of android's important function :)
later i'll try to recreate your problem
from android-colorpickerpreference.
I am already in your debt for producing such a terrific
colorpickerPreference, which apart from the problem I am having is great -
it is the only one I know which shows the color directly in the Preference
screen. Very attractive.
Whatever help you may care to provide would be most welcome, but I know from
my own experience that it is almost always something I have done wrong. It
is just that in this case what I am doing seems exactly the same as what I
do for other preferences, which seems to work, so I don't really know where
to go.
Thanks again for your help thus far.
Peter Webb
----- Original Message -----
From: "attenzione"
[email protected]
To: [email protected]
Sent: Monday, April 04, 2011 3:47 PM
Subject: Re: [GitHub] Color Preference default incorrect?
[attenzione/android-ColorPickerPreference GH-7]
ListPreference, stores value as String & CheckBoxPreference stores value
as Boolean, so u call mysharedPreferences.getString &
mysharedPreferences.getBoolean respectively. Maybe it's some issue with
SharedPreferences.getInt..
but shouldn't, it's one of android's important function :)
later i'll try to recreate your problemReply to this email directly or view it on GitHub:
#7 (comment)
from android-colorpickerpreference.
glad to read this strings :)
from android-colorpickerpreference.
You need to override onSetInitialValue:
@OverRide
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
onColorChanged(restoreValue ? getValue() : (Integer) defaultValue);
}
from android-colorpickerpreference.
Thanx roflharrison, i will add this in near future, when i will be available for some programming actions :)
at this time i'm not able to do this.
btw someone can modify code & make pull request, so i'll accept it
from android-colorpickerpreference.
Same problem here, the color:
<color name="colorPrimary">#FF2196F3</color>
Getting recognized as: #FF2096F3 (the 1 is a 0)
Any idea how to fix this?
from android-colorpickerpreference.
Related Issues (20)
- How would I apply the integer? HOT 1
- R cannot be resolved to a variable
- Some parts of view is disappeared when screen is rotated
- Selecting Color doesn't update preview HOT 3
- Works on Android 1.5 HOT 1
- Sample activity causing trouble because of its placement in the project tree HOT 1
- Setting defaultValue HOT 1
- Not Available HOT 1
- ColorPickerPreference cannot be cast to android.support.v7.preference.Preference
- Unsupported major.minor version 52.0 HOT 2
- Fatal Exception: java.lang.NullPointerException HOT 3
- Program type already present: net.margaritov.preference.colorpicker.BuildConfig
- Feature request HOT 1
- Error
- Typo in comment of ColorPickerPreference.java HOT 1
- Can't use many transparent default values
- gradle fails to sync HOT 1
- Prevent wrong chars in hex input HOT 1
- richis
- Package is not avaliable in mavenCentral and jcenter is deprecated 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 android-colorpickerpreference.