Accessing Resources in xml
Consider the following resource XML
res/values/strings.xml file that includes a color resource and a string
resource:
< ?xml version="1.0"
encoding="utf-8"? >
< resources > < color name="opaque_red" > #f00 < /color > < string name="hello" > Hello! < /string > < /resources > |
Now you can use these resources in
the following layout file to set the text color and text string as follows:
< ?xml version="1.0"
encoding="utf-8"? >
< EditText xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textColor="@color/opaque_red" android:text="@string/hello" / > |
Now if you will go through previous
chapter once again where I have explained Hello World! Example, and I ' m sure
you will have better understanding on all the concepts explained in this
chapter. So I highly recommend to check previous chapter for working example
and check how I have used various resources at very basic level.
No comments:
Post a Comment