APIDEMO PREFERENCE 学习 ACTIVTIY
Prefercence 观察来看设计思想应该是简化设置的UI的界面布局所用。
主题是 PreFerenceActivity
1:xml
Code实现:
亦可以自定义PreFerecnce控件 MyPreference
使用:
可以在Activity 主UI 线程中 使用preference xml 的值
1:先在主UI中定义
/*
* If this were my app's main activity, I would load the default values
* so they're set even if the user does not go into the preferences
* screen. Another good place to call this method would be from a
* subclass of Application, so your default values would be loaded
* regardless of entry into your application (for example, a service or
* activity).
*/
PreferenceManager.setDefaultValues(this, R.xml.advanced_preferences, false);
2: 使用
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
final int counter = sharedPref.getInt(AdvancedPreferences.KEY_MY_PREFERENCE, 0);
更多相关文章
- 浅谈Java中Collections.sort对List排序的两种方法
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- python list.sort()根据多个关键字排序的方法实现
- Titanium 使用刘明星的Jpush module做android端的消息推送
- android.support.v7使用,出错处理
- android 中使用TextView实现分段显示不同颜色的字符串