Coder Social home page Coder Social logo

Comments (4)

martin-stone avatar martin-stone commented on August 15, 2024

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.

tomsr avatar tomsr commented on August 15, 2024

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.

martin-stone avatar martin-stone commented on August 15, 2024

You should probably use getDefaultSharedpreferences(). "listColor" is probably not the name of your preferences file.

from hsv-alpha-color-picker-android.

tomsr avatar tomsr commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.