color-picker
½éÉÜ£º
Ò»¸öƯÁÁµÄÑÕÉ«Ñ¡Ôñ¶Ô»°¿ò
ÔËÐÐЧ¹û£º
ʹÓÃ˵Ã÷£º
¶Ô»°¿òµÄÐÎʽ£º
Ö±½Óн¨Ò»¸ö¶Ô»°¿ò£¬È»ºóµ÷ÓÃshow·½·¨
ColorPickerDialogFragment d = new ColorPickerDialogFragment();
// set the palettes
d.setPalettes(new AbstractPalette\[\]
{
ArrayPalette.fromResources(this, "basecolors", R.string.base_palette_name, R.array.base_palette_colors, R.array.base_palette_color_names),
new FactoryPalette("rainbow", "Rainbow", ColorFactory.RAINBOW, 16)
});
d.show(getSupportFragmentManager(), tag);
»òÕßÔÚactivity»òÕßFragmentÖÐʵÏÖColorPickerDialogFragment.ColorDialogResultListener£º
@Override
public void onColorChanged(int color, String colorName, String paletteName)
{
// do something with color
}
@Override
public void onColorDialogCancelled()
{
// handle cancelled color picker dialog
}
ͨ¹ýIntentÀ´µ÷ÓÃ
AndroidManifest.xml
<activity android:name="org.dmfs.android.colorpicker.ColorPickerActivity" >
<intent-filter>
<action android:name="org.openintents.action.PICK_COLOR" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
È»ºóÕâÑùµ÷ÓöԻ°¿ò
ColorPickerActivity.start(context, CODE_PICK_COLOR);
Õ⽫µ÷ÓÃactionΪorg.openintents.action.PICK_COLORµÄIntent£¬È»ºóÔÚonActivityResult(int, int, Intent)ÖлñµÃÑÕÉ«Öµ£º
@Override
protected void onActivityResult(int code, int result, Intent data)
{
if (result == RESULT_OK && code == CODE_PICK_COLOR)
{
Integer color = ColorPickerActivity.getColor(data);
}
}
已下载
0