Saturday, May 14, 2011

Addition in Android development

Recently, I created a blog post on basic math in iPhone development, so I figured why not do the same for Android programming. Basically, you need to create two editText fields, a textView and a button. Below is an example of source code that could be used within the button method to add two numbers.

String s1,s2;
Integer v;

s1 = edit1.getText().toString();
s2 =edit2.getText().toString();
v = Integer.parseInt(s1) + Integer.parseInt(s2);

textview1.setText(v);

Recently, I created a World War II trivia game for iPhone. It's called CODENAME:WW2 Trivia. If you're interested in downloading, click here.

Thursday, May 5, 2011

Inheritance for Android development

Inheritance is a very simple, but important part of iPhone and Android programming. Most object oriented programming relies on inheritance. Basically, if you think of genetics and how one inherits traits from his or her parents, the same principle relies in inheritance of classes.

When one class inherits from a super class, it inherits all of its methods. So, this will cut down on the amount of code you use and makes life more simple.

For example

public class test extends Activity

In this example test inherits from the Activity class.

New World War II trivia game for iPhone- Click here to download

Monday, May 2, 2011

String concatenation iPhone

Adding strings in Objective C can be done in a few different ways. I like to use combined string identifiers like the example below.

NSString *first = @"win";
NSString *second = @"dow";
text.text = [NSString stringWithformat:@"%@%@",first,second];


New World War II trivia game for iPhone- click here