gpt4 book ai didi

java - 当 ColorPickerPreference 库不是首选项时添加它

转载 作者:行者123 更新时间:2023-12-01 14:38:30 24 4
gpt4 key购买 nike

我正在尝试将 ColorPicker 添加到我的应用程序中。我看到了很多 ColorPickers(来自 API 示例的 the one from CyanogenAmbilWarna libraryHoloColorPickerColorPickerPreference )。我认为最适合我的应用程序的是最后一个,但我不需要在偏好上使用它。

所以,我想要的是当我单击按钮时在我的项目中使用这个库,然后从 SharedPreferences 中获取结果代码(我想,我不知道),并根据需要使用该颜色对于我的应用程序。

我尝试仅使用某些类(仅 ColorPickerDialogColorPickerViewColorPickerPanelViewAlphaPatternDrawable ),然后我认为我必须这样做:

ColorPickerDialog dialog = new ColorPickerDialog(Main.this, Color.BLACK);
dialog.show();

现在我不知道如何才能获得所选的颜色。

我还在我的项目中添加了 xml view .

有什么想法吗?

最佳答案

要知道您选择的颜色是什么,您需要:

color=dialog.getfinalColor();

所以,我认为这个问题很容易解决。但现在的问题是找到一个监听器来检测对话框何时关闭,然后保存变量“颜色”。

关于java - 当 ColorPickerPreference 库不是首选项时添加它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16240129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com