Ads

субота, 31. мај 2014.

How to create your first Android app (with pictures)

App Inventor lets you create Android apps without any knowledge in programming. How cool is that! Thanks to Google. You design your apps on a web page, assemble pieces of logic blocks together on an editor, test your app on an emulator or on your phone while you are designing; cool, huh? Your projects are hosted by Google. All you have to do is design and join the pieces together like a puzzle game.

WildLifeShow 1.png 
 On your browser, go to My Projects. Click the New button to create your app app. This will make a new dialog box to open.


WildLifeShow 4.png

Now drag a Vertical Arrangement component on Screen1 window where we will display our images later. This will create a vertical arrangement component on our Screen1. The name of the component will be automatically VerticalArrangement1. 

WildLifeShow 5.png 
 
All the components you drag to Screen1 can be seen under Components pane. We need to change some properties of the VerticalArrangement1. Select VerticalArrangement1 under Components pane. On Properties pane you will see the properties of the component you selected. Change VerticalArrangement1's Width to Fill parent and Height to 350 pixels.  

WildLifeShow 6.png 
 
Drag an Image component and place it inside VerticalArrangement1 component that we placed earlier on Screen1. Note that the name of Image component is Image1  

WildLifeShow 7.png 
 
Get a Label component and place it below VerticalArrangement1. Take note of the name of our Label component which is automatically set to Label1. 

We need to change some properties of the Label component. Select Label1 under Components pane and change the following-
  • Check the Font/Bold property.
  • In the Text property, type Tap On A Button To Hear Them. You can type anything you like.
  • Change the Text Alignment to center.
  • Set Text/Color to Blue.
  • Change the Width to Fill parent.
WildLifeShow 8.png 
 
  1. WildLifeShow 9.png 
    Now we need a Horizontal/Arrangement component where we will place our three buttons. Get a Horizontal/Arrangement component and place it below our Label component. Take note of the name HorizontalArrangement1.
     
  2. WildLifeShow 11 1.png
    11
    We also need to play sound. For us to be able to do that, drag a Player component and place it anywhere on Screen1. Since Player is a non-visible component, this will appear underneath Screen1 window.
  3. AppInventor WildLifeShow 27.png
    12
    One more tiny thing we should do is change the Title of Screen1 to Wild LifeShow. For us to do that, select Screen1 on Components pane and change the Title property under Properties pane to Wild LifeShow.
  4. 13
    Let's get our picture and sound files added. For our app, we used the following image and sound files which you should download to your computer.
  5. 14
    Under Media pane, click Add and upload the image and sound files one by one.

    WildLifeShow 12.png
  6. 15
    You should see now the following under your Media pane.

    WildLifeShow 13.png
  7. 16
    Now that we are done with the design portion of our app, we need to implement the interactions among the components we have. For instance, we want the Elephant picture to be displayed and Elephant sound file to be played once Button1 is clicked. In order to do that, we got to open the Blocks Editor window. Click on the Open the Blocks Editor button.

    WildLifeShow 14.png
  8. WildLifeShow 15.png
    17
    On the Blocks Editor window, click on My Blocks which will display all the components we placed on our app through Designer/Viewer window. Locate Button1 and click on it. Now we can see all the events and different properties of Button1. Select and drag the Button1.Click event block on the Blocks Editor space as shown below.
  9. WildLifeShow 16.png
    18
    Now under My Blocks, locate and click Image1. This will show the events and properties of Image1. Get the Image1.Picture and place it inside the Button1.click block. Once you place it, you should hear a click sound which means the blocks are properly connected to each other.
  10. WildLifeShow 17.png
    19
    We need to set the source of the picture to our image Elephant.png. To do that, click on Built-In tab, then locate and click Text block. Drag the text block over to the right and connect it to Image1.Picture block.

    WildLifeShow 18.png
  11. 20
    The text block indicates which picture to display. Click on text of text block and change it to Elephant.png. Careful with the casing. If you have saved the Elephant.png file as elephant.png, then type elephant.png.

    WildLifeShow 19.png
  12. WildLifeShow 20 1.png
    21
    Now locate the Player1 and place the Player1.Source block below Image1.Picture block. Connect a text block to Player1.Source block and change the text of text block to Elephant.wav.
  13. WildLifeShow 21 1.png
    22
    Grab and place Player1.Start block below Player1.Source block.
  14. WildLifeShow 22 1.png
    23
    Do the same thing for Button2 and Button3. For Button2, use Bird and for Button3, use Penguin. Your blocks should look like the snapshot below.
  15. 24
    You are done! Now it's time to see our app in action. If your Android device/phone is connected to your computer, you can click on Package for Phone on Designer/Viewer window in your web browser and then choose Download to Connected Phone. This will install the app on your phone.

    WildLifeShow 25.png
    • If you don't have a phone connected, you can launch an emulator from the Blocks Editor window. Click on New emulator and it will launch an emulator for you.

      WildLifeShow 23.png
    • After the emulator is launched, click on Connect to Device... button. You should see the emulator that you just launched. Click on that and it will load the app on the emulator.

      WildLifeShow 24.png
 

Нема коментара:

Постави коментар