duanhong169 / ColorPicker

🎨 A color picker for Android. Pick a color using color wheel and slider (HSV & alpha).
Apache License 2.0
361 stars 82 forks source link

Cannot resolve symbol #1

Closed TadyTheFish closed 5 years ago

TadyTheFish commented 5 years ago

I'm a total beginner in AS. I'm trying to use your library for my app and can't get it working.

colorPickerView.subscribe((color, fromUser) -> { // use the color }); colorPickerView is colored red (cannot resolve symbol) what did I forgot?

Thank you!

duanhong169 commented 5 years ago

The colorPickerView must be declared and assigned before use.

If you use the butterknife library, just do this:

https://github.com/duanhong169/ColorPicker/blob/a2cd044f28b596b8780b11044f1e89d152f55741/app/src/main/java/top/defaults/colorpickerapp/MainActivity.java#L22

or, you can use the findViewById:

ColorPickerView colorPickerView = findViewById(R.id. colorPickerView);
TadyTheFish commented 5 years ago

Thank you so much! It kinda worked but then the app would crash! The XML file was the problem. I had to change from <top.defaults.view.ColorPickerView to <top.defaults.colorpicker.ColorPickerView because <top.defaults.view.ColorPickerView wuld always return null and it didn't have any preview in the design. It works now! Thank you!