Android programming made so easy even your grandma can do it pt. 2

in #education7 years ago (edited)

I would like to begin the second part of tutorial with disclaimer:

If you have ever done any programming this tutorial is not meant for you. It is prepared for complete beginners who have never seen and try any coding.

In the part 1 (If you missed it, it is availabe here), we finished setting up our developement environment. From the first part, we should have our demo project with one label and one button still saved in app inventor.

Because every app which contains only two elements and does nothing is useless, we will add some action to our first button.


Hello world!

It always starts with Hello World, with any programming language you start to learn.

Log into app inventor and select "demoProject" from the list.

After the project opens, you can see the "Blocks button" on the right top part of the screen. This is the section where we can apply actions to our first app.

Capture1.PNG

In the blocks viewer, we have various categories of blocks divided in groups by their action and under the blocks we can see our interface elements. If you renamed your elements, you should be able now to find out which element you are working on.


Capture2.PNG

Let's begin by applying action to our btnMyFirst. Click on the button and another panel will appear, with button specific options.

We will select "when btnMyFirst" block. Click and drag it to the center of the screen.

All blocks have a specific shape which will allow us to connect them only to the blocks that are supported with selected operation.


Capture3.PNG

Let's proceed by clicking on our lblMyFirst on the left side of the screen. Again, panel with element options will appear and it will look different than button options. That is because for buttons and other input elements we can apply event listeners, for example onClick or touchDown, which are not applicable for elements that are used for displaying data - like our label.

From the label options, let's select select "LblMyFirst.text to" block, drag it to the center screen and connect it to the "when btnMyFist.Click". If you check the shape of both blocks, you can see that they will fit together. But we still have an empty connector at the end of "Set Label Text To".


Capture4.PNG

Lets click on blocks group Text, select first option " " and connect it to our empty label block. This is called string and is still empty. Click on it and type Hello world!.

Our code by now means: When btnMyFist is clicked, lblMyFirs will change its text to "Hello world!"


Capture5.PNG

We can test it out on our phone by connecting it through AI companion, as described in previous post.

Congratulations, your first app is complete! After it opens on the phone you can test it out.

In these first two posts we got to know the environment, now we are ready to start exploring more advanced features.

Any comments, questions and suggestions are most welcome and if you found it interesting, please stay tuned.

Sort:  

grandma is very excited and waiting for more!)

Grandma shall get more for sure :)

Good post thanks for this info

I am glad you like it, more interesting stuff will follow. Keep updated

Thanks

This comment has received a 0.15 % upvote from @booster thanks to: @hamzaoui.

This comment has received a 0.10 % upvote from @booster thanks to: @hamzaoui.

Just finishing a cross-platform app for a client with Xamarin/Visual Studio. Lots of weird issues. Not sure if Xamarin is ready for prime time yet. I'll definitely be using native development platforms next time around. Android Studio seems pretty easy to work with. Good post.

Well, Xamarin is completly other level :) For cross-platrofm I was using Cordova, but it can not be compared to native apps. The biggest advantage is, just one code to maintain.

Coin Marketplace

STEEM 0.19
TRX 0.13
JST 0.028
BTC 63894.70
ETH 3178.14
USDT 1.00
SBD 2.63