Android中资源文件用法简单示例
本文实例讲述了Android中资源文件用法。分享给大家供大家参考,具体如下:
一、XML文件间资源文件的使用
引用格式:
attribute="@[packagename:]resourcetype/resourceidentifier"
example:
有strings.xml、color.xml、dimen.xml文件,使用其中的参数
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="@dimen/standard_border"> <EditText android:id="@+id/myEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/stop_message" android:textColor="@color/opaque_blue" /> </LinearLayout>
二、使用系统的资源
使用android本地系统资源要这样写:
在XML文件中的使用方法:
<EditText android:id="@+id/myEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@android:string/httpErrorBadUrl" android:textColor="@android:color/darker_gray" />
注意引用本地资源的文件的时候都加了android这个前缀。
更多关于Android相关内容感兴趣的读者可查看本站专题:《Android资源操作技巧汇总》、《Android文件操作技巧汇总》、《Android操作SQLite数据库技巧总结》、《Android操作json格式数据技巧总结》、《Android数据库操作技巧总结》、《Android编程之activity操作技巧总结》、《Android编程开发之SD卡操作方法汇总》、《Android开发入门与进阶教程》、《Android视图View技巧总结》及《Android控件用法总结》
希望本文所述对大家Android程序设计有所帮助。
相关文章
Android开发中实现IOS风格底部选择器(支持时间 日期 自定义)
这篇文章主要介绍了Android开发中实现IOS风格底部选择器(支持时间 日期 自定义)的相关资料,需要的朋友可以参考下2016-11-11
Android中使用itemdecoration实现时间线效果
这篇文章主要介绍了Android中使用itemdecoration实现时间线效果,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2021-02-02
Android 7.0系统webview 显示https页面空白处理方法
今天小编就为大家分享一篇Android 7.0系统webview 显示https页面空白处理方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-07-07
Android通过json向MySQL中读写数据的方法详解【写入篇】
这篇文章主要介绍了Android通过json向MySQL中读写数据的方法,结合实例形式较为详细的分析了Android json类的定义、调用及php接收json数据并写入mysql的实现技巧,需要的朋友可以参考下2016-06-06


最新评论