Android 颜色选择的实现(3)

当对话框关闭时,即选择完颜色后,我们就要马上回去更新文本的颜色和将颜色值保存到键值里面,代码如下:

@Override          protected void onDialogClosed(boolean positiveResult) {              if (positiveResult) {                  mCurrentColor = mCPView.getColor();                  summary.setTextColor(mCurrentColor);                  SharedPreferences.Editor editor = getEditor();                  editor.putInt(getKey(), mCurrentColor);                  editor.commit();                  callChangeListener(new Integer(mCurrentColor));              }          }    

通过重写,onDialogClosed 回调函数,到这一步整个的封装就己结束,在XML可以通过如下使用

<com.terry.util.ColorPickerPreference                  android:key="colorpiker" android:persistent="true" android:summary="@string/app_name"                  android:dialogTitle="@string/str_fontscolor" android:title="@string/str_fontscolor" />     

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwfsdd.html