Android使用SharedPreferences实现本地轻量存储,ToggleButton,TextView边框详解
来源:互联网 发布:产品在淘宝没有展现 编辑:程序博客网 时间:2024/06/10 05:03
工作内容:
1.使用轻量级存储方式,将设置存储到本地SharedPreferences。
【
注意:
SharedPreferences.editor editor = sharedPreferences.edit();
editor.clear();//存储时使用,可防止重复存储时,存储失败等等错误
edit.putInt(....)
】
2.ToggleButton的使用。
3.TextView【组件边框详解】
学习分享:
给组件添加边框(设置圆角)
Corners——radius设置圆角的度。【没有则表示直角边框】
Solid——color填充背景色。
Stroke——width设置边框的厚度。
Gradient——endColor渐变最后颜色。
Item——bottom去掉下边框的厚度(抵消在stroke中设置的width)。
SharedPreferencesd的使用
import android.content.Context;import android.content.SharedPreferences;public class SharedpreferenceUtil { private static SharedPreferences sharedPreferences = null; private static final String DATAKEY = "DATAKEY"; //是自定义的一个常量(sharedPreferences在本地存储文件的名称) private static final String startKey = "startKey", notifyKey = "notifyKey"; /** * 将设置写入本地DATAKEY.xml(所在位置:data/data/+context.getPackageName+/shared-prefs/DATAKEY.xml) * * @param context 上下文 * @param isStart 存储的数据 */ public static void writeSet_start(Context context, int isStart) { if (sharedPreferences == null) { /** * 得到SharedPreferences的一个实现类的对象 * context.MODE_PRIVATE 是一个int型的数据表示sharedPreferences的类型 */ sharedPreferences = context.getSharedPreferences(DATAKEY, context.MODE_PRIVATE); } //获取一个编辑器Editor对象 SharedPreferences.Editor editor = sharedPreferences.edit(); /** * 将设置写入本地文件 * startKey 是存取的钥匙(取数据的时候用它去取到相应的存储值) */ editor.putInt(startKey, isStart); editor.commit(); } //获取本地sharedPreferences的xml文件里存储的设置信息 public static int getSet_start(Context context) { if (sharedPreferences == null) { sharedPreferences = context.getSharedPreferences(DATAKEY, context.MODE_PRIVATE); } //获取startKey对应的值 return sharedPreferences.getInt(startKey, -1); }}
0 0
- Android使用SharedPreferences实现本地轻量存储,ToggleButton,TextView边框详解
- Android中实现本地缓存,存储(SharedPreferences存储)
- Android本地存储方案 SharedPreferences
- 轻量存储 shapeUtil
- android轻量数据库SQLite的使用
- MarkDown轻量使用
- Android轻量存储值SharedPreference存世实例
- Android 存储数据SharedPreferences详解
- Android sharedpreferences使用详解
- android应用的本地存储SharedPreferences类
- Android本地存储之SharedPreferences源码解析
- android 本地SharedPreferences存储到使用sqlite数据库存储的转换
- Android上常用的几种本地数据存储方式:1、使用SharedPreferences存储数据
- Android 使用SharedPreferences数据存储
- 使用SharedPreferences存储android用户信息
- Android实现二维码扫描(仿微信,轻量Zxing)
- 【Android-UI】TextView底部边框实现
- 自定义TextView 灵活使用Shape实现边框
- shell语句备份mysql数据库表内容,生成sql文件的tar包
- history命令查看操作时间
- OpenCV-2.RGB Normalized
- Hrbust 1491 游河【最大流模板题】
- Codeforces Round #366 (Div. 2) C. Thor
- Android使用SharedPreferences实现本地轻量存储,ToggleButton,TextView边框详解
- 基于matlab实现图像的直方图均衡
- eclipse在ubuntu16.04下cpu占用率高的问题
- Spring data jpa 自定义SQL语句遇到错误Not supported for DML operations
- C++ 操作Excel问题
- Python pickle
- hash素数表(备用)
- manacher算法
- Mysql同时执行多个select语句——union