手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android中资源文件用法简单示例
Android中资源文件用法简单示例
摘要:本文实例讲述了Android中资源文件用法。分享给大家供大家参考,具体如下:一、XML文件间资源文件的使用引用格式:attribute="@...

本文实例讲述了Android中资源文件用法。分享给大家供大家参考,具体如下:

一、XML文件间资源文件的使用

引用格式:

attribute="@[packagename:]resourcetype/resourceidentifier"

example:

有strings.xml、color.xml、dimen.xml文件,使用其中的参数

<"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本地系统资源要这样写:

复制代码 代码如下:CharSequence httpError = getString(android.R.string.httpErrorBadUrl);

在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 Studio使用教程图文详解

android通用xml解析方法

Android应用中的组件功能

Android 混淆代码详解及实例

Android软件开发环境搭建

Android Service中方法使用详细介绍

Android控件之ToggleButton的使用方法

Android 文件操作方法

android自动更新软件版本

android 照相功能的简单实例

精品推荐
分类导航