Android中資源檔的使用
來源:互聯網
上載者:User
一、XML檔案間資源檔的使用 引用格式:attribute=”@[packagename:]resourcetype/resourceidentifier” example: 有strings.xml、color.xml、dimen.xml檔案,使用其中的參數<?xml version=”1.0” encoding=”utf-8”?><LinearLayoutxmlns: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”><EditTextandroid: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檔案中的使用方法: <EditTextandroid: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這個首碼。