Choose Window➪Show View➪Other. 2. Expand Java and choose Properties.
Chapter 4: Designing the User Interface
Placing an image on the screen The first thing you add is the phone image to the screen. This is the phone image that you see in Figure 4-4, earlier in this chapter. First you need uh, yeah the phone image. You can download that from the book’s source code that is available online, or you can use your own. Adding images to your project is simple. We simply drag them over and then reference them in the project. 1. Drag the phone image into the resdrawable-mdpi folder in the Eclipse project, as shown in Figure 4-8. Figure 4-8: Dragging the image file into the res draw- able- mdpi folder. Notice that you see two states of the application: regular, as shown earlier in Figure 4-2, and silent, as shown earlier in Figure 4-3. 2. Drag the other phone image — the silent one or one of your own — into the resdrawable-mdpi folder. To follow along with the rest of the chapter, the names of the images should be as follows: • Regular mode image: phone_on.png • Silent mode image: phone_silent.png If your images are not named accordingly, you can rename them now. Your Eclipse project should now look like what is shown in Figure 4-9. 106 Part II: Building and Publishing Your First Android Application Figure 4-9: The Silent Mode Toggle project with the phone images. When you dragged the images into Eclipse, the ADT recognized that the proj- ect file structure changed. At that time, the ADT rebuilt the project because the Build Automatically selection is enabled in the Project menu. This regen- erated the gen folder, where the R.java file resides. The R.java file now includes a reference to the two new images that were recently added. You may now use these references to these resources to add images to your layout in code or in XML definition. You’re going to declare them in XML layout in the following section. Adding the image to the layout Now it’s time to add the image to the layout. To do that, you need to type the following into the main.xml file, overwriting the current contents of the file: ?xml version=”1.0” encoding=”utf-8”? LinearLayout xmlns:android=”http:schemas.android.comapkresandroid” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” ImageView android:id=”+idphone_icon” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center_horizontal” android:src=”drawablephone_on” LinearLayout 107Chapter 4: Designing the User Interface
Parts
» android application development for for dummies
» Developing Spectacular Android Applications
» Prepping Your Development Headquarters
» Click the New button see Figure 2-13. Click
» Click the curved-arrow icon on the right side of the screen to go to the workbench.
» Start Eclipse, if it’s not already running. 2.
» Type a name in the Name field.
» Type Prepping Your Development Headquarters
» Click the OK button. Android ADT is selected in the Work With drop-down menu, and the
» In the Build Target section, select Android 2.2.
» In the Properties section, type Hello Android in the Application Name box.
» In the Package Name box, type com.dummies.android.helloandroid.
» In the Min SDK Version box, type 8. Your screen should now look similar to Figure 3-5.
» Click the Create AVD button. Close the Android SDK and AVD Manager dialog box.
» Your First Android Project Your First Android Project
» Designing the User Interface Designing the User Interface
» Designing the User Interface
» Choose Window➪Show View➪Other. 2. Expand Java and choose Properties.
» Select the main.xml tab. 2. Add the background property to your LinearLayout:
» Verify that the definition for LinearLayout looks like this:
» Save the file. 5. Select the Layout tab to view the visual designer.
» Coding Your Application android application development for for dummies
» In Eclipse, choose Run➪Run or press Ctrl+F11 to run the application.
» Return to the home screen by clicking the home button on the emulator.
» Coding Your Application Coding Your Application
» If Eclipse is not open, open it now and open the main.xml file in the layouts
» Choose the Extract Android String option.
» Understanding Android Resources android application development for for dummies
» Turning Your Application into a Home-Screen Widget
» When the Add to Home Screen dialog box is visible, select Widgets, as shown in Figure 7-5.
» When the Choose Widget dialog box is visible, choose Silent Mode Toggle, as shown in Figure 7-6.
» Publishing Your App to the Android Market
» Click the Continue button to pay the developer fee with Google Checkout.
» On the order confirmation page see Figure 8-11, click the Place Your Order Now button.
» Click the Android Market Developer Site link.
» Read the terms and then click the I Agree, Continue link.
» On the Android developer home page refer to Figure 8-14, click the Upload Application button.
» For the Application .apk file, choose the .apk file that you created
» In the Screenshots section, add two screen shots of your application.
» Set the title of your application.
» Set the description for your application.
» Set the promo text of your application.
» Designing the Task Reminder Application
» Install the application in the emulator, and click the Menu button.
» Going a la Carte with Your Menu Going a la Carte with Your Menu
» Going a la Carte with Your Menu
» Handling User Input android application development for for dummies
» Is this a long-running task?
» Does the user need to be able to perform an advanced action in the dialog box?
» Does the user need to answer a question such as “Are you sure?” with a value of Yes or No?
» Does the user simply need to be alerted?
» Getting Persistent with Data Storage
» Reminding the User with AlarmManager
» Updating the Android Status Bar
» Working with Android’s Preference Framework
» Working with Android’s Preference Framework Working with Android’s Preference Framework
Show more