AttributeSet、Settings
来源:互联网 发布:永川茶竹网软件 编辑:程序博客网 时间:2024/06/05 03:04
//程序首先执行此函数
public TypedefDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
//通过此句得到布局里的自定义变量dialogMessage里的值,
括号里第2个参数其实是一个resId,要得到其字符串值,在布局里只能用
dialogMessage = "@string/dialogMessage",不能用dialogMessage = "字符串"形式。否则得到的是R.string.empty默认值。
dialogMessage = attrs.getAttributeResourceValue(null, "dialogMessage", R.string.empty);
}
TextView.setText(dialogMessage);//dialogMessage为int型,此函数通过resId得到字符串
TypedArray a = //TypedArray其实就是一个存放资源的Array,context.obtainStyledAttributes(attrs,R.styleable.RadioButton);
this.mValue = a.getString(R.styleable.RadioButton_value);
a. recycle();
<declare-styleable name="RadioButton"><!-- 控件名称-->
<attr name="value" format="string"/><!-- 属性名称,类型-->
</declare-styleable>
Setting里面的一些设置也是通过数据库来保存的,今天才去看个究竟。那通过数据库来保存就会有Provider了,所以就会有SettingsProvider了。数据库的路径就是:/data/data/com.android.providers.settings. 但我们平常获取这里面的数据不是直接通过ContentResolve而是android已经封装了一层,通过Settings这个类来获取,就像MediaStore一样。比如我们获取飞行模式:Settings.System.getInt(mContext.getContentResolver(),Settings.System.AIRPLANE_MODE_ON, 0)
- AttributeSet、Settings
- AttributeSet类
- android AttributeSet
- settings
- settings
- Settings
- settings
- Settings
- Settings
- settings
- Settings
- settings
- Settings
- AttributeSet自定义控件方法
- TypedArray、attrs.xml、AttributeSet
- AttributeSet自定义控件
- android AttributeSet API
- Android-自定义AttributeSet属性
- c++ 锁
- Maven Compile Encoding 乱码问题解决
- Flash Player 11, AIR 3, and Flex/Flash Builder 4.6
- Linux平台weblogic 启动异常慢的问题
- linux的高端内存分析
- AttributeSet、Settings
- C#连接firebird
- response.sendRedirect的执行原理
- MBTiles
- 分布式数据库架构--排序分页分组探讨
- 手把手教你玩转ARP包
- 2011-9-22 21:41:11
- netbeans 快捷键
- vb 框架设计