Git Product home page Git Product logo

Comments (4)

jaredrummler avatar jaredrummler commented on August 26, 2024

The ColorPreference implements ColorPickerDialogListener and is called to update the preference. Instead of using a ColorPickerDialogListener, you can add a OnPreferenceChangeListener as shown below:

ColorPreference colorPreference = (ColorPreference) findPreference("REPLACE_WITH_KEY");
colorPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
  @Override public boolean onPreferenceChange(Preference preference, Object newValue) {
    if ("REPLACE_WITH_KEY".equals(preference.getKey())) {
      String newColor = Integer.toHexString((int) newValue);
      Log.d(TAG, "New default color is: #" + newColor);
    }
    return true;
  }
});

from colorpicker.

valeriogiocondi avatar valeriogiocondi commented on August 26, 2024

I'm sorry, I did not explain well, I just need to get color selected from picker, and you describe (in your source code) ColorPickerDialogListener.onColorSelected as the method I'm looking for:

/*
Callback that is invoked when a color is selected from the color picker dialog.
*

  • @param dialogId
  • The dialog id used to create the dialog instance.
    
  • @param color
  • The selected color
    

*/
void onColorSelected(int dialogId, @ColorInt int color);

from colorpicker.

jaredrummler avatar jaredrummler commented on August 26, 2024

I'm assuming you are using ColorPreference. You don't need the ColorPickerDialogListener if you are using the ColorPreference. If the user changes the color then you can use onPreferenceChange as shown above.

from colorpicker.

valeriogiocondi avatar valeriogiocondi commented on August 26, 2024

I get it. I took the demo as example, that's why I used onColorSelected.

Thanks a lot, your colorPicker is awesome :)

from colorpicker.

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.