Day 5 – Learning Android Development

I didn’t do much today. I spent almost the whole day playing skyrim but right now I’ve been able to do some things.

I continued with the video tutorials of TheNewBoston. I created a menu for my app, which uses a special child class of activity called ListActivity. You create an array in order for the activity to show the menu. Then that array gets used by the setListAdapter method from the ListActivity class to provide the cursor for the menu. From there you define inside the method onListItemClick that when you click an item from the menu, it must take you to that activity.


So I had to change the flow of activities as well. Now the launcher activity or the one that starts is the menu, then you can choose +- 1(or in the future other activities) and the title screen will appear first, followed by the actual activity. since I had to do that, I decided to refactor some class names and xml file names. What followed was a bunch of errors everywhere so I spent quite a while correcting them. But I couldn’t correct a peculiar one, eclipse told me that it couldn’t find R in R.layout. It was constantly trying to import android.R but that was not a class I needed. After a while I figured out that something was wrong in an xml file name I was trying to use for setContentView, I was using upper case which is not possible for xml files. At least I got to know the debugger better.

After that I worked a bit more on xml, discovered how beautiful android:padding and android:weightSum are.

Day 2 – Learning Android Development

Today has been a bit slow because I’m getting acquainted with all the new vocabulary, both from Java and the Android SDK. I’m still following the Android training from I need to take my time to go over the methods and XML to really understand what each line does. I know most would just get the tutorial done as fast as they can to move on to more advanced things, but I’m doing this right now because I want to avoid  “what did this thing do again?” or “what am I supposed to do here?”.

Following the tutorial, I created an input box with a button “Send” next to it. You input something (text) in that box and then hit send, which leads you to another screen or “activity” that will show you just what you wrote.

main activity
new activity










Simple? Not for your first time. The XML part was rather straight forward, you define the layout of the input box and button for your main activity (the app’s home screen). The tricky part starts when you have to link things to one another. On the XML button layout, you write onClick: and then the name of the method, which means it has to run when you click the button. This method needs to be defined in the .java file corresponding to that XML file. In this method, you put whatever you want do when you press that button. Then you have to link this method to the new class, which corresponds to the new activity. You do this by building a new “Intent” in the method, which is an object that can create new activities. In the new class which is invoked by the intent, you have to get the message which is located in the previous class. This is done by the intent object, in the previous class, you have to say to the intent object to carry/store the message. So you can retrieve this message and display it. And that’s it.

After that I started looking at the activity lifecycle and the different stages an activity can be at: created, started, resumed, paused, stopped and destroyed.

The first two happen really fast, usually when you click on an app, the activity gets created and started almost instantly. Then follows the resumed stage, which is when the activity is running and you as a user can use it. When it’s paused, the activity is partially visible and stopped is when it’s not visible. If the activity is paused then when you go back it resumes, when the activity is stopped and you go back, it’s restarted. Finally, destroyed is when you shut down the app completely.