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...
Name your application (MyFirstApp, etc.), and set the Minimum SDK
Start with a Blank Activity, name it MainActivity.
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.
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.
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.
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.
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.
#Step 4
Click the button!
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!