When you make this change, type it by hand to try the code-completion feature. As you begin typing "R.layout.main" the plugin will offer you suggestions. You'll find that it helps in a lot of situations.

Instead of passing setContentView() a View object, you give it a reference to the layout resource. The resource is identified as R.layout .main, which is actually a compiled object representation of the layout defined in /res/layout/main.xml. The Eclipse plugin automatically creates this reference for you inside the project's class. If you're not using Eclipse, then the class will be generated for you when you run Ant to build the application. (More about the R class in a moment.)

Now re-run your application — because you've created a launch configuration, all you need to do is click the green arrow icon to run, or select Run > Run History > Android Activity. Other than the change to the TextView string, the application looks the same. After all, the point was to show that the two different layout approaches produce identical results.

Tip: Use the shortcut Ctrl-F11 (Cmd-Shift-F11, on Mac) to run your currently visible application.

Continue reading for an introduction to debugging and a little more information on using other IDEs. When you're ready to learn more, read Application Fundamentals for an introduction to all the elements that make Android applications work. Also refer to the Developer's Guide introduction page for an overview of the Dev Guide documentation.

<?xml version="1.

0" encoding="utf-8"?>


<string name=

"hello">Hello, Android! I am a string resource!</string>

<string name=

"app name">Hello, Android</string>


0 0

Post a comment