import android.preference.Preference; //导入方法依赖的package包/类

@Override

public boolean onPreferenceChange(Preference preference, Object value) {

String stringValue = value.toString();

if (preference instanceof ListPreference) {

// For list preferences, look up the correct display value in

// the preference's 'entries' list.

ListPreference listPreference = (ListPreference) preference;

int index = listPreference.findIndexOfValue(stringValue);

String title = index >= 0 ? String.valueOf(listPreference.getEntries()[index]) : "";

//Exibir o tempo total de funcionamento do registrador depois do ultimo reset.

if (OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_OFTEN_LOGGER_RESET.equals(preference.getKey())){

Context context = preference.getContext();

long durationLoggerRunning = preference.getSharedPreferences().getLong(OhaEnergyUseSyncHelper.ENERGY_USE_SYNC_DURATION_LOGGER_RUNNING,0);

preference.setTitle(String.format(context.getString(R.string.pref_title_energy_use_sync_often_logger_reset), title));

preference.setSummary(String.format(context.getString(R.string.pref_summary_energy_use_sync_often_logger_reset), OhaHelper.convertMillisToHours(durationLoggerRunning)));

} else {

// Set the summary to reflect the new value.

preference.setSummary(title);

}

} else if (preference instanceof RingtonePreference) {

// For ringtone preferences, look up the correct display value

// using RingtoneManager.

if (!TextUtils.isEmpty(stringValue)) {

Ringtone ringtone = RingtoneManager.getRingtone(

preference.getContext(), Uri.parse(stringValue));

if (ringtone == null) {

// Clear the summary if there was a lookup error.

preference.setSummary(null);

} else {

// Set the summary to reflect the new ringtone display

// name.

String name = ringtone.getTitle(preference.getContext());

preference.setSummary(name);

}

}

} else {

// For all other preferences, set the summary to the value's

// simple string representation.

preference.setSummary(stringValue);

}

return true;

}

java trackid_Java Preference.getContext方法代码示例相关推荐

  1. java preference_Java Preference.setSelectable方法代码示例

    import android.preference.Preference; //导入方法依赖的package包/类 private void configureChildAccountPreferen ...

  2. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

  3. java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例

    import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...

  4. java invalidate_Java Component.invalidate方法代码示例

    import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...

  5. java hasmoreelements_Java IOException.hasMoreElements方法代码示例

    import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...

  6. java methode_Java Method.getTypeParameters方法代码示例

    import java.lang.reflect.Method; //导入方法依赖的package包/类 private void validateRuleMethod(MethodRuleDefin ...

  7. java setmethod_Java Operation.setJavaMethod方法代码示例

    import com.sun.tools.internal.ws.processor.model.Operation; //导入方法依赖的package包/类 private void createJ ...

  8. java cancel_Java RunnableFuture.cancel方法代码示例

    import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类 @Test public void testSnapshotAsyncC ...

  9. java getevent_Java ActionEvent.getWhen方法代码示例

    import java.awt.event.ActionEvent; //导入方法依赖的package包/类 @Override final public void actionPerformed(A ...

最新文章

  1. Scala协变与Java泛型
  2. 酒店前厅计算机的作用,浅谈智能化对酒店前厅员工的服务质量和影响
  3. 解决wiremock中velocity脚本(.vm)中文编码乱码问题
  4. JVM源码---教你傻瓜式编译openjdk7(JAVA虚拟机爱好者必看)
  5. 三角剖分求多边形面积的交 HDU3060
  6. 在错误的数据上,刷到 SOTA 又有什么意义?
  7. jstl-按照html的形式输出至页面
  8. leetcode python3 简单题118. Pascal's Triangle
  9. python——sort方法、sorted函数——排序
  10. 一元多项式的带余除法
  11. 站群优化及优化技巧解析
  12. 简约个人介绍主页源码,免费创建个人主页
  13. Hexo博客开发之——theme主题备份上传失败
  14. API函数的调用过程
  15. elasticsearch(es)的安装-macOs
  16. 知网研学不同电脑端同步无效问题
  17. Android TV 焦点控制
  18. 浅谈:企业需要什么样的技术总监?技术总监需要具备什么能力?
  19. 京峰教育Linux笔记
  20. 电脑中的计算机为什么打不开怎么办,电脑当中msconfig打不开怎么办-电脑自学网...

热门文章

  1. 【Android工具】安卓应用市场哪家强?chrome浏览器apk下载插件,play安装包下载,妈妈再也不用担心我找不到安装包了...
  2. 【ASIC设计】ASIC设计流程
  3. C1之路 | 备考C1
  4. 一个docker镜像中的目录删除不了问题
  5. 用java将excel数据导入txt
  6. 原创 深度 技术:WatchStor焦点周刊创刊号
  7. Windows环境下搭建React Native
  8. jQuery基础之(二)jQuery中的$
  9. saltstack模块 --cp
  10. hdu1428(记忆化搜索)