本文實例講述了Android中資源文件用法。分享給大家供大家參考,具體如下:
一、XML文件間資源文件的使用
引用格式:
attribute="@[packagename:]resourcetype/resourceidentifier"
example:
有strings.xml、color.xml、dimen.xml文件,使用其中的參數(shù)
<?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>
二、使用系統(tǒng)的資源
使用android本地系統(tǒng)資源要這樣寫:
<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這個前綴。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android資源操作技巧匯總》、《Android文件操作技巧匯總》、《Android操作SQLite數(shù)據(jù)庫技巧總結(jié)》、《Android操作json格式數(shù)據(jù)技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android開發(fā)入門與進階教程》、《Android視圖View技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對大家Android程序設(shè)計有所幫助。
新聞熱點
疑難解答