Be careful not to mix upper- and lowercase letters in your image names. Your images should be named using lowercase letters only. If you mix in some uppercase letters, you will get an error message from Eclipse when you try to use the file.

After you copy the image to the correct directory, refresh the project. The helloworld.png image should now appear in your project view, in the drawable directory, as shown in the following illustration.

"fi Package Explorer Hierarchy^ 1=1 Q

l^j and roid_ programme rs_guide,H»l I oWorldlm

Open and take a look at its code. Eclipse should have added a pointer to helloworld.png. Your file should look similar to this:


* This class was automatically generated by the

* aapt tool from the resource data it found. It

package android_programmers_guide.HelloWorldImage;

public final class R {

public static final class attr { }

public static final class drawable {

public static final int helloworld=0x7f020000; public static final int icon=0x7f020001;

public static final class layout {

public static final int main=0x7f030000;

public static final class string {

public static final int app_name=0x7f040000;

With a clean application shell as your starting point, and an available handle to the image you want to display, you can begin to add your code. You are going to look at this application from two perspectives: that of the XML-based UI and that of the code-based UI.

0 0

Post a comment