Skip to content

First Tutorial for SiGMobile, Create your first Android app

Notifications You must be signed in to change notification settings

Perilynn/FirstTutorial

Repository files navigation

First Tutorial

alt tag

The first meeting tutorial, building your first Android app!

#Step 1

Installing Android Studio

Go to http://developer.android.com/sdk/index.html and download Android Studio. Install it. Make sure you have the JDK installed on your computer: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

#Step 2 Creating a new Project

Open up Android Studio and Start a new Project...

alt tag

Name your application (MyFirstApp, etc.), and set the Minimum SDK

alt tag alt tag

Start with a Blank Activity, name it MainActivity.

alt tag alt tag

Gradle should invocate your project, and take you into the activity!

#Step 2 Adding Content

Go to your activity_main.xml. the XML specs the appearance of the file, while the Java activities add functionality. Drag a Button (under Widgets) onto the screen.

alt tag

If you go to the Text tab in the XML, you'll be able to see the code generated by Android Studio for the Button.

alt tag

Run your code if you wish, and you'll see the new Button next to your Hello World!

Now that we have a button, let's make it do something.

#Step 3 Adding functionality to your content

Let's define a method in our MainActivity called buttonOnClick, which will execute an action when the Button is clicked.

alt tag

In this method, lets make a TextView variable that will change the Text displayed when the button is clicked. You can do this by first linking a TextView variable to the one being displayed, and then updating it. It will update when the method is called.

alt tag

Let's add a couple things to our XML to support the actions: If it isn't already there, add the line:

android:id="@+id/textView"

inside your TextView so that the buttonOnClick function can access and change the View. Additionally, add the following line:

android:onClick="buttonOnClick"

to your Button. This has your program execute the specified method when the button is clicked.

alt tag

#Step 4

Run your app! alt tag

Click the button!

alt tag

If you enjoyed this tutorial and want to learn more, check out the rest of the tutorials on this Github and come to SiGMobile meetings! We'll see you there!

About

First Tutorial for SiGMobile, Create your first Android app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published