1 / 39

Android Hello World

Android Hello World. Click on Start and type eclipse into the textbox. You can right click on the icon and choose Pin to Start Menu for easier access later.

piera
Download Presentation

Android Hello World

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Android Hello World

  2. Click on Start and type eclipse into the textbox

  3. You can right click on the icon and choose Pin to Start Menu for easier access later

  4. Click on the icon, you will be prompted to choose a workspace (where your programs will go). You can make your choice the default. Click OK.

  5. Your first time on a machine, you will prompted to designate the location of the Android SDK in preferences

  6. Click on Browse, choose Computer/C:/Android-sdks

  7. Click Apply and OK.

  8. Start a new Project Method 1: File/New/Android Application Project

  9. Start a new Project Method 2: File/New/Project, then in the dialog choose Android/Android Application Project

  10. Fill in the fields of the dialog: Application Name, Project Name, Package Name. For now I made the Minimum Required SDK and Target SDK the same. Click Next.

  11. Accept defaults on next few dialogs. Next. Next.

  12. More dialogs. Next. Finish.

  13. Click on the resource (res) folder, the layout folder, the activity_main.xml file. Then click on the Graphical Layout tab to see what the “screen” will look like

  14. Click on Window/Android Virtual Device Manager

  15. Click New ….

  16. Supply a name, choose a device to emulate, a target version of Android and a CPU (typically Atom or ARM). Click OK. If an option you wanted is missing. You may need to go to Windows/Android SDK Manager and download it. After that you should probably restart Eclipse.

  17. Click on the drop-down arrow next to the green Run as arrow. Choose Run Configuration

  18. Double click on Android Application on the left panel. Then click on Browse to choose the project to run

  19. Then click on the Target tab and choose the AVD to use for the emulation. Click Apply and Run.

  20. The emulator starting – this sometimes takes a long time!

  21. Emulated Hello World project

  22. Drag a Button onto the layout

  23. Click on the activity_main.xml tab to see the effect in XML code

  24. Return to Graphical Layout and change the id and the Text in the Properties area

  25. Drag a TextView from the Form Widgets onto the layout

  26. Change the id and Text in the Properties area

  27. Expand src and the package, click on MainActivityJava. Also click on the MainActivity.java tab at the top

  28. Click on the Save All icon

  29. Inside the onCreate method in the MainActivity class add the line of code Button btnClickMe = (Button) findViewById(id.btnClickMe)

  30. Place the mouse over the red squiggly underlined Button and choose Import Button

  31. Expand the Imports to see the result

  32. Associate an setOnClickListener with the Button. Type btnClickMe.setOnClickListener(new OnClickListener(){ }); This action causes two problems. The first is cured by another import – This time import android.view.View.OnClickListener I had trouble choosing the Import from the list and just ended up Typing it in up in the Import area

  33. The second problem is cured by adding the unimplemented onClick method

  34. Put the code you want executed when the user clicks the button inside the onClick method

  35. Set up a TextView (including declaring and casting). Note the need to Import.

  36. Add line to change the text

  37. Sometimes the project does not seem to open up right away. Drag the lock, click OK, expand the menu

  38. Click OK. Click on project icon.

  39. Before and after the click

More Related