代码拉取完成,页面将自动刷新
#ColorSelector4Android
##ColorSelector4Android是安卓平台下的颜色选择器
###Activity模式使用方法
启动ColorSelectActivity
//生成一个Intent指向ColorSelectActivity
Intent intent = new Intent(this, ColorSelectActivity.class);
//在Intent中放入上一次的颜色数据
intent.putExtra(ColorSelectActivity.LAST_COLOR,lastColor);
//启动ColorSelectActivity
startActivityForResult(intent, 0);
接收返回的数据
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
//通过ColorSelectActivity.RESULT这个键来取值
lastColor=data.getIntExtra(ColorSelectActivity.RESULT,0x000000);
view.setBackgroundColor(lastColor);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
####注意在使用ColorSelectActivity时记得在自己项目的AndroidManifest文件中加入:
<activity android:name="zhou.colorpalette.ColorSelectActivity"/>
###DialogFragment模式使用方法
ColorSelectDialogFragment colorSelectDialogFragment=new ColorSelectDialogFragment();
//设置颜色选择完成后的回调事件
colorSelectDialogFragment.setOnColorSelectListener(new ColorSelectDialogFragment.OnColorSelectListener() {
@Override
public void onSelectFinish(int color) {
lastColor=color;
MainActivity.this.view.setBackgroundColor(lastColor);
}
});
//设置上次选择的颜色(可选)
colorSelectDialogFragment.setLastColor(lastColor);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
//需要打开时调用show方法
colorSelectDialogFragment.show(ft, "colorSelectDialogFragment");
###AlertDialog模式使用方法
ColorSelectDialog colorSelectDialog = new ColorSelectDialog(this);
//绑定颜色选择完成后的回调事件
colorSelectDialog.setOnColorSelectListener(new ColorSelectDialog.OnColorSelectListener() {
@Override
public void onSelectFinish(int color) {
// ...
}
});
//设置上次的颜色(可选)
colorSelectDialog.setLastColor(lastColor);
//要显示Dialog时别忘了调用show方法
colorSelectDialog.show();
##具体操作请查看Demo
by zzhoujay
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型