Changes

Jump to: navigation, search

Creating an Example Android Application

21 bytes added, 19:58, 27 October 2016
m
Text replacement - "<table border="0" cellspacing="0">" to "<table border="0" cellspacing="0" width="100%">"
<googlehtmlet>BUY_ANDROIDandroid44</googlehtmlet>
== Stopping a Running Application ==
<googlehtmlet>ADSDAQBOX_FLOWadsdaqbox_flow</googlehtmlet>
When building and running an application for testing purposes, each time a new revision of the application is compiled and run, the previous instance of the application running on the device or emulator will be terminated automatically and replaced with the new version. It is also possible to manually stop a running application from within the Eclipse environment.
To return to the main Java development perspective, simply click on the Java button in the Eclipse toolbar.
<googlehtmlet>BUY_ANDROIDandroid44</googlehtmlet>
== Modifying the Example Application ==
The next step in this tutorial is to modify the user interface of our application so that it displays a larger text view object with a different message to the one provided for us by Eclipse.
The user interface design for our activity is stored in a file named activity_android_testfragment_android_test.xml which, in turn, is located under res -> layout in the project workspace. Using the Package Explorer panel, locate this file as illustrated in Figure 4 12:
[[Image:AndroidTest_project_in_explorereclipse_android_test_layout.png|The Eclipse Package Explorer panel]]
Figure 4-12
[[Image:android_44_user_interface_buildereclipse_androidtest_in_layout_tool.png|The Eclipse graphical layout tool]]
Figure 4-13
== Reviewing the Layout and Resource Files ==
Before moving on to the next chapter, we are going to look at some of the internal aspects of user interface designs and resource handling. In the previous section, we made some changes to the user interface by modifying the activity_android_testfragment_android_test.xml file using the Graphical Layout tool. In fact, all that the Graphical Layout was doing was providing a user-friendly way to edit the underlying XML content of the file. In practice, there is no reason why you cannot modify the XML directly in order to make user interface changes, and in some instances, this will actually be quicker than using the graphical layout tool. At the bottom of the Graphical Layout panel are two tabs labeled Graphical Layout and activity_android_testfragment_android_test.xml respectively. To switch to the XML view simply select the activity_android_testfragment_android_test.xml tab as shown in Figure 4-17:
[[Image:AndroidTest_xml_layouteclipse_fragment_layout.png|Editing the XML for an Android UI layout]]
Figure 4-17
</pre>
As a demonstration of resources in action, change the string value currently assigned to the welcomestring resource then run the application again. Note that the application has picked up the new resource value for the welcome string.
== Summary ==
<googlehtmlet>BUY_ANDROIDandroid44</googlehtmlet>
 
<htmlet>ezoicbottom</htmlet>
<hr>
<table border="0" cellspacing="0" width="100%">

Navigation menu