[Samsung Galaxy Fit GT 5670] speed_bot:
This is basic guide to start to off app development for android..........

This is just a basic guide and not a comprehensive one which covers the whole lot of it but a rather a guide to get a basic simple app of your own running without any issues

Requirements

A bit of java

linux , darwin or a windows 7 machine

internet connection

basic idea of how programming works

sdk with atleast one api installed and configured path

Part 1 setting up everthing and explaining used variables and terms

Now let's get started

[windows}

Download eclipse as any other software and install it by the .exe file and follow the instructions

(linuc macosx )

if you are on a older ditribution of linux the minimum required version of eclipse 3.6 is not supplied via ubuntus main repository ....

so you need to download it from the eclipse official website and install it....

[common}

Installing ADT(Android developer tools) plugin

open up eclipse

Start Eclipse, then select Help > Install New Software.

Click Add, in the top-right corner.

In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:

https://dl-ssl.google.com/android/eclipse/

Click OK.

If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).

In the Available Software dialog, select the checkbox next to Developer Tools and click Next.

In the next window, you'll see a list of the tools to be downloaded. Click Next.

Read and accept the license agreements, then click Finish.

If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.

When the installation completes, restart Eclipse.

Configure the ADT Plugin

Once Eclipse restarts, you must specify the location of your Android SDK directory:

In the "Welcome to Android Development" window that appears, select Use existing SDKs.

Browse and select the location of the Android SDK directory you recently downloaded.

Click Next.

If you haven't encountered any errors, you're done setting up ADT and can continue to Next Steps.

the path to the sdk is case sensitive and absolute so be careful guys....

Now you have virtually everything set up to start building apps

go to file>new>project>android>android application project

something like this will pop up

now

the first three fields are yours to choose

now the second part

The build sdk is the sdk that you are targeting in laymans words its like building a building on a certain specific site.....

the minimum required sdk

now if choose this as froyo(api 8) your app will run on froyo os and above and will be compatible with older flavours of android....

once you are done creating a new project hit finish

now you will see something like this

now the calculator is my app name the name that you gave a few minutes ago will be yours...

Now the android is basically divided into three main things

The android manifest

The src folder

The xml

The android manifest basically is a traffic police in lay mans words

it determines which activity comes first when it ends etc...

note:i will be referring the xml to a activty

the src folder contains all of your java

xml's are the skeltel system of android they define the size layout colour or the whole look of your android project....

Note: dont tinker with the gen folder you alone will be responsible for your mistakes

in this tutorial you will be working with only src,res and xml's as i cant dig deeper into it because its a subject too broad to teach....

now lets get started

navigate to res > layout double click on main_activty.xml

below the screen click on activty_main.xml next to graphical layout...

something like this will appear

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />

</RelativeLayout>

this is the text appearing to you

Note this is auto generated....

now i will explain each line of it with my limited knowledge

]<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

This is the auto generated refernce by eclipse yours may vary and might not be same as mine

android:layout_width="match_parent"
android:layout_height="match_parent"

now you can see that the layout is set to match_parent by deafult

match_parent utilizes the whole screen into your layout...

and observe this guys the

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

the relative layout has started with <relativelayout and ended with > anything code started should be finished up by > or />

both are literally same

now the next junk of code to deal with

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />

Textview is basically a method by google to display some text on the screen...

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

These two lines suggest that your app has both vertcal and horizontal layout

android:text="@string/hello_world"

this is the text being displayed on your graphical layout

now go to layout > values > strings.xml

double click it

you will see something like this

now basically strings are resource files used to show text on display...

the string name cant have any spaces if it has then u will see errors

but the value of the string can have spaces

Activity

change the text in value field and see the result in graphical layout of the xml

now you basically need to use strings for each and every text that has to be displayed.......

End of part 1

Part 2

Adding of buttons and modifying them

now guys lets add some buttons to our project

navigate to src

in that you will find a java file open it (.java)

you will find something like this

package com.exmple.addandsubract;

import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Layout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_layout, menu);
return true;
}
}

now you might be wondering what is this crap code ...

now lets add buttons

navigate into layout open up the xml

your screen will show up this

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />

</RelativeLayout>

now within the closing of relative layout

copy paste this

<Button
android:id="@+id/bsub"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="79dp"
android:text="@string/sub" /

every button must have an id for our convenience we have added a bsub as our program is to add and subtract a number

android:layout_width="match_parent"

the layout width specifies the size of the width of the button

as i have said before match_parent is to occupy the whole screen..if you want it smaller you can set it in dp(density pixels)

android:text="@string/sub"

you cant hard code stuff into the button u need to refernce it to a string i have referred it to the string sub

for this to work it requires you to add a string by the name sub in strings.xml

now do the same code again for button add

after this you will have something like this showing up

now that we have our button's set up we need to make this work (in real add java to it)

to accomplish this we need to link xml's to java

this may sound like greek and latin but guys stick with it u will understand everything

now below

public class Layout extends Activity {

type this

int counter=0;
Button add,sub;
TextView display;

as u may all know we should define a variable before we use them

as we are working with number (basically integars we use integar to define them

now we basically define display as textview

now coming to the real java part

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_item);

after this chunk of code

type

counter=0;

the counter is the number which should be displayed on the screen for us

i have decided to start with 0 you can set it to any number that you prefer

now type this

add = (Button) findViewById(R.id.badd);
sub = (Button) findViewById(R.id.bsub);

what this basically says is that add is a button and its id(in the xml) is badd.. findviewbyid is the method for referencing

now its the same for sub button too

display = (TextView) findViewById(R.id.textView1);

this will set our display to textview1 which is our activity.xml this may sound as bloat to you but its handy when working with many xmls

now type

add.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

display.setText("Your total is " + counter );

}
});

i will explain what this does

add.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

display.setText("Your total is " + counter );
}
});

type add. then all lists will popup select onclicklistener(this makes the button clickable)

within the brackets of onclicklistener type new(as its a new button) leave a space type view.onlclicklistener(again you will see popups

now what is between this two brackets is what happens when the button is clicked now add this in between these brackets

add.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
counter=counter+1;
display.setText("Your total is " + counter );
}
});
sub.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter=counter-1;
display.setText("Your total is " + counter );

}
});

counter=counter-1;

this decrements the counter value by 1

after the counter is decremented we need to change the display to show the value of it

we do that by typing this

counter=counter-1;
display.setText("Your total is " + counter );

now do this for both buttons test the app on emulator

Have doubts comment below

liked the thread rate it that gives me moral confidence and motivation