这部分内容,就要把我们的值存到sharepreference里面,其实很简单..
1,在onDialogClosed 写好要保存的方式
@Override protected void onDialogClosed(boolean positiveResult) { // TODO Auto-generated method stub super.onDialogClosed(positiveResult); if (positiveResult) { setTime(); } }
2,写我们的setTime()方法即可..
private void setTime() { // shopStart.gett @SuppressWarnings("unused") //检查是否需要关闭依赖... final boolean wasBlocking = shouldDisableDependents(); int currentHour = shopStart.getCurrentHour(); int currentMinute = shopStart.getCurrentMinute(); //持久化值 persistString(currentHour+":"+currentMinute); //再次检查是否需要关闭依赖... final boolean isBlocking = shouldDisableDependents(); //更新所有依赖改变 if(isBlocking != wasBlocking) { notifyDependencyChange(isBlocking); } }
截个小图来表示一下:
顺便给个建议,如果上网找不到资料的话,直接debug 源码,从源码中找出规律不失为一个好办法..
本文转自 liam2199 博客,原文链接:
http://blog.51cto.com/youxilua/794733
如需转载请自行联系原作者