Changes

Jump to: navigation, search
no edit summary
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[Understanding Android Views, View Groups and Layouts|Previous]]<td align="center">[[Kindle Fire Android 4 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Android User interface in Java Code|Next]]</td>
<tr>
<td width="20%">Understanding Android Views, View Groups and Layouts<td align="center"><td width="20%" align="right">Creating an Android User Interface in Java Code</td>
<google>BUY_KINDLE_FIREBUY_ANDROID</google>
By far the easiest and most productive mechanism for designing a user interface for a Kindle Fire an Android application is to make use of the Graphical Layout tool. This is supplied as part of the Android ADT plug-in and is accessible from within the Eclipse IDE. The goal of this chapter is to provide an overview of how to create a user interface using this tool. The exercise included in this chapter will also be used as an opportunity to outline the creation of an activity starting with a “bare-bones” Eclipse project.
Having covered the use of the Graphical Layout tool, the chapter will also provide an overview of the concepts behind manually writing and editing XML layout resource files before introducing the Hierarchy Viewer tool.
The first step in this phase of the example is to create a new Eclipse project. Begin, therefore, by launching Eclipse and selecting the File -> New -> Android Application Project… menu option. Within the resulting new project dialog, name both the application and project LayoutSample.
Enter the package name using your reverse domain name and the application name as outlined in [[Creating an Example Kindle Fire Android Application ]] (for example com.mycompany.layoutsample), or use the default com.example temporary name if you do not yet have a domain name. Select Android 2.2 as the minimum SDK and the latest Android version for the Target SDK and Compile with settings and click Next to proceed.
In previous examples, we have requested that Eclipse create a template activity for the project. We will, however, be using this tutorial to learn how to create an entirely new activity and corresponding layout resource file manually within Eclipse, so make sure that the toggle next to Create Activity is switched off on the Configure Project screen. Accept the default launcher icon settings on the next screen before clicking on Finish to create the new project.
== Running the Application ==
All that remains is to test that the application runs. Right-click on the LayoutSample project name in the Package Explorer panel and select Run As -> Android Application. Select either the simulator or a physical Kindle Fire Android device and wait for the application to start. Assuming the absence of errors, the application and activity should launch and appear exactly as designed using the Graphical Layout tool.
== Manually Creating an XML Layout ==
<google>BUY_KINDLE_FIREBUY_ANDROID</google>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[Understanding Android Views, View Groups and Layouts|Previous]]<td align="center">[[Kindle Fire Android 4 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating an Android User interface in Java Code|Next]]</td>
<tr>
<td width="20%">Understanding Android Views, View Groups and Layouts<td align="center"><td width="20%" align="right">Creating an Android User Interface in Java Code</td>
</table>

Navigation menu