mobile app

Read Chapter 2, creating the HealthyRecipes app.

In this chapter you learn how to put an image and a button on your layout.

No matter which development environment you use (Eclipse and add-ons, or Android Studio) this is what you do:

1. Put a TextView and ImageView and button on your layout (activity_main.xml) 

2. Create a second layout (recipe.xml) that has only TextViews on it

3. Create a java class (Recipe.java) to go with the second layout

4. Add a button listener to the java code for the main layout (i.e. add it to MainActivity.java) so that when the button is clicked the second layout (recipe.xml) appears. 

Android Studio handles things a little differently from the way the book says, but the main difference is that Eclipse had wizards and pop-ups that led you through creating some of these new features and saved you having to write the java code, whereas in Android Studio you have to type in the java code yourself. 

Here are the changes I found I had to make:

1. Adding an image. There is no drawable-hdpi folder as stated on page 44. Drag and drop your image (guacamole.png) into the folder called ‘drawable’. Then in the properties box of the ImageView go to src and type @drawable/guacamole  Note there is no .png. This puts the image in the ImageView

2. To add a layout, in your project right click on layout and choose New -> Layout Resource File. You should alter the layout from linear to relative.

3. To create a java class, in your project under java, right click on your package name (mine is called com.examples.jeanmehta.healthyrecipes) and choose New _> java class. Make sure this new class extends from the same class as MainActivity. 

public class Recipe extends AppCompatActivity

4. You have to alter the HealthyRecipes Manifest by hand (so ignore pages 55-57). Fig 2-19, page 54 shows you what it currently looks like.Then add the one line of code , line 25 on Figure 2-23, page 58.

 

5. It’s the same as the book from page 58 onwards. 

Run it on an emulator. You will find you cannot return from the second page (the ingredients and directions). On the emulator go to Menu ->Manage Apps -> HealthyRecipes ->Force close. This will allow you to run it a second time. 

(Sometimes you make a mistake and need to edit your app.

Using Eclipse: If you make changes in Eclipse and save them, you probably need to uninstall your app from the emulator before running your app again. To uninstall: Menu ->Manage Apps -> HealthyRecipes ->Uninstall.)

Using Android Studio: You can just run the app again and the new version will download onto the emulator

When you have finished HeathyRecipes, complete one of the end of chapter exercises that has one or two stars, and one that has three stars.

Grade: Healthy Recipes: 10 points

Either Case Project 2-1, 2-2, 2-3, or 2-4 (one or two star exercises) 10 points (The instructions are a little confusing, just follow the algorithm. It is ONE school, or ONE hostel and needs 2 layouts, one button, and 2 java classes).

Either Case Project 2-5 or 2-6 (three star exercises) 20 points  (These need your own images, 3 layouts, 3 java classes, and 2 buttons)

NOTE: Images must be in png format and the names must be all lowercase (I learned this the hard way!)

In case you have a similar question and need it answered for you just say write my essay. At Academized we have all the most qualified academic writers and tutors, for all your assignments, essays, cases studies, discussion posts, project proposals, research papers, discussion posts, nursing assignments, admission essays, blog articles, and other forms of academic work.

If you don’t want a custom paper, just buy a pre-written essay from Buy College Essay.