简体   繁体   中英

Color Picker how to change TextView

I have a problem. How to use ColorPickerDialog ? How do I set ColorPickerDialog so as to change my text color?

You can use this project instead of a demo app

// initialColor is the initially-selected color to be shown in the rectangle on the left of the arrow.
// for example, 0xff000000 is black, 0xff0000ff is blue. Please be aware of the initial 0xff which is the alpha.
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, initialColor, new OnAmbilWarnaListener() {
        @Override
        public void onOk(AmbilWarnaDialog dialog, int color) {
                // color is the color selected by the user.
        }

        @Override
        public void onCancel(AmbilWarnaDialog dialog) {
                // cancel was selected by the user
        }
});

dialog.show();

Be careful to this (I never used it myself):

You need to link against Android 3.0 or higher since there is an XML attribute layerType in use. This doesn't mean you can use this only for applications requiring Android 3.0 to operate. It works even in Android 1.6. You just need to select Android 3.0 (API level 11) on the project settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM