Android Tutorial

(avery) #1

By : Ketan Bhimani


130 

<?xml version=”1.0” encoding=”utf-8”?>



ResourceRoundup
name=”hello”>Hello World, ResourceRoundupActivity
#ff0000
14pt
#F00

Save the strings.xml resource file. The Eclipse plug-in automatically
generates the R.java file in your project, with the appropriate
resource IDs, which enable you to programmatically access your
resources after they are compiled into the project. If you navigate
to your R.java file, which is located under the /src directory in your
package, it looks something like this:

package com.androidbook.resourceroundup;
public final class R {
public static final class attr {
}
public static final class color {
public static final int prettyTextColor=0x7f050000;
}
public static final class dimen {
public static final int textPointSize=0x7f060000;
}
public static final class drawable {
public static final int icon=0x7f020000;
public static final int redDrawable=0x7f020001;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
public static final int hello=0x7f040001;
}
}


Now you are free to use these resources in your code. If you
navigate to your Resource Round upActivity.java source file, you
can add some lines to retrieve your resources and work with them,
like this:
Free download pdf