Tag Archives: TheNewBoston

Day 10 – Learning Android Development

Today I finished the video tutorials on beginner java programming from TheNewBoston. I didn’t pay attention to videos 60-78 and the last 4 videos because they were about JFrame (GUI development) and I already have XML to worry about for android so there’s no point seeing this subject right now. Here’s an overview of what I saw today:

  • Overriding a method: Following from where I ended yesterday on polymorphism. Overriding a method is when you change an inherited method, but leave the same amount of arguments and return the same datatype.
  • Overloaded method: inherited method but with different amount of arguments as the super class’.
  • Abstract class: A class which is too abstract that it’s better not to create objects from it, it serves as a base for inheritance and polymorphism. Methods can be abstract too.
  • Polymorphic array:  make an array of objects, and loop through the objects while calling the same method: x.eat();  y.eat();  z.eat();  etc. and some may be overridden methods but you can still loop through them because they have the same name.
  • The File class: purpose is to keep data in a text file after a program closes so the data can be used once the program restarts again. checking if files exist, creating new files, adding data to files, read from files.
  • Exception handling: examples of try/catch in a loop.

The plan for tomorrow is to see all 36 java game development tutorials from him. It should be just review and learning syntax because I already know some of the basics of game development (2D) in python. After tomorrow, it’s back to android development on full speed!

 

Day 9 – Learning Android Development

Today I continued with the java tutorials from TheNewBoston. I’m doing this to be able to better understand the programming language behind android development. I watched videos 20-57, I stopped at polymorphism  to get a night’s sleep on that subject and review it tomorrow.

The videos covered a great deal of subjects, most of them I already knew from python so I just quickly covered them, focusing on syntax. Here is a little overview of what I saw today:

  • averaging program: take a few numbers using a while loop and return the average.
  • for loops: Same thing as a while loop for the most part.
  • compound interest program: calculate the compound interest over x years, printing the total amount of income for each year
  • do while loop.
  • Math class: some method examples.
  • Random class: revised again.
  • Array and matrix
  • Enhanced for loop: much like python’s for loop (traversal).
  • The ellipse “…”: Takes in a dynamic number of arguments and makes an array out of them. (e.g. public int doThis(int…numbers); //arguements will be stored in the array a.
  • “this” keyword: refers to local variables inside methods or to the same method (constructor recursion?).
  • multiple constructors: made possible by the “this” keyword. A slightly different constructor gets invoked again inside a constructor’s body of the same class.
  • toString method: for object representation, whenever you pass an object as a string, if you have a toString method in that object, that’s the string that’s going to be used.
  • Enumeration: constants that are also objects.
  • static keyword: a static variable/attr. is the same in all instances. If you change it, it changes in all instances. Can be used to count how many instances have been created. static methods can be accessed without creation of an instance by the statement Classname.methodname();
  • final keyword:  final means that you can not modify the variable no matter what, like a constant, and you write it in caps by convention.
  • inheritance:  when a class can use methods from another class. private methods cannot be inherited. the class inherits the methods by using the extends keyword. so now objects from a subclass can use methods from the parent class. inherited methods can be changed across sub-classes, which leads us to polymorphism.
  • polymorphism: super and sub classes have the same method name (inherited), but the method in each subclass can be changed to do a different action from what the original inherited method did. So although the method name remains the same, the action can be different across sub classes. With polymorphism you can  pass objects as arguements for other class’ methods.

The plans for tomorrow are to finish the rest of the series (30 videos), I’ll probably just look through the more relevant ones. There’s also a video tutorial series that he has on java game development so I’ll probably check that out tomorrow or the day after tomorrow.

Day 7 – Learning Android Development

My connection has been fixed so today I was able to resume the TheNewBoston tutorials. Today I learned some new interesting things while working on a second app from the tutorial.

The app consists of a text input box, that when typing certain commands it will do things. For example you can type in WTF and it will print it out below the input box, but with random colors and text sizes,  I got introduced to the Random class in Java to implement this. I also learned about password input type, which can hide what you are writing in the input box like a password. I did that by putting a toggle where ON = hide the input text.

This slideshow requires JavaScript.

I learned that a final variable cannot be changed. Also that you cannot compare two strings with “==”, you have to use the  “.contentEquals()” method or a variant thereof. when you use == for strings, you are checking if the memory location of both strings are the same instead of checking to see if they contain the same word.

The tutorial introduced me to a switch statement which i had never heard of before. Now I know it’s a conditional statement and know how to use one. It is replaceable by the traditional” if/else” statement, but the latter is more of a choice, semantically speaking. If this is true, then you do something, if not, then you do something else. While a switch is more of a case e.g.this switch refers to this type of case. At least that’s how I see it, and I’m just a newbie.

I also got introduced to implementing interfaces. I had always seen examples where you extend a class, which means that in your current class you can use methods from another class. When you implement an interface though, you have to use all the methods. An interface is a reference type, like a class is, but can only contain constants, method signatures, and nested types. They don’t have method bodies and cannot be instantiated like a class can, they can only be implemented by classes. The interface I used is View.OnClickListener which is a public static interface.

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.

This slideshow requires JavaScript.

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 4 – Learning Android Development

Today I did a bit of everything: design, sound and coding. I followed TheNewBoston again, this time videos 11-19. I’m really happy by the way he teaches and I feel I’m learning things at a good pace.

I started out by creating a title design in Photoshop for the app I created yesterday, which i call “+- 1”. Note that most of the code for this app is copied from TheNewBoston’s tutorial, the rest of it is code I’ve added myself or are tweaks from his code. The design is all mine.

Image
Title actitvity
Image
Main Activity

 

 

 

 

 

 

 

 

 

 

The title comes out whenever you start the app (onCreate phase). It lasts 1.5 seconds and then the main activity comes out. You can’t go back to the title activity once you pass it. This is intended as you don’t want the user to go back to the title when he presses the return key. It’s done by putting finish() at the onStop() method, this finishes the class once the activity is not visible.

I redid the layout of the main activity as well as you can see its now a dark grey gradient background and bone colored font. Plus I added sound to the buttons once you press them. For the sound I used Sunvox.

I started on arrays that will make it easier to switch from activities but I will continue on that tomorrow.

The Java is progressing more and more. I haven’t looked at additional resources for it and just by looking at the android tutorials I’ve been able to relate most of it to Python as I learned OOP from there. Creating classes, inheritance, methods, attributes, invoking methods, etc. I’ve been able to handle correctly most of it and I’m getting to know the relatively harder syntax (Python’s syntax is way more simple). But there’s sometimes I don’t get what he’s coding. Maybe I will follow some of his tutorial videos on Java programming.

Day 3 – Learning Android Development

It seems the next chapters in developer.android don’t really hold you by the hand as the first one where they guide you through building your first app. Instead they introduce you to the basics like managing activity lifecycles, supporting different devices, supporting different platform versions, building dynamic UIs, etc, but they only show you how to implement those specific things and provide you code snippets. What I need is more tutorials like the first one, where they show you everything.

I went to reddit/androiddev to see what people were using to learn android development. Someone referred TheNewBoston’s android videos. I checked them out. They are very good, at least the ones I’ve seen. He starts from scratch and the videos are never longer than 10 minutes each so each of them focuses on something specific. What is really good is that you can hear him explaining and at the same time showing you how to do it. If you don’t get something you can just rewind or look at the youtube comments. Most of the time if there’s a problem it gets pointed out in the comments.

By following his first 10 videos I was able to create a little app that adds 1 to a counter when you press a button. Simple, and the Java was easy, but I feel that I’m grasping the essentials more and more now.

Adding + 1