This tutorial will be a introduction into android development.
This is a basic tutorial and is only meant to help a begginer programmer on the feel of android applications and how they are developed. So don't expect a big application because this is not. Also this will help you to begin with setting the Android into eclipse est.

This application will contain:
  • A button
  • A Toggle Button
  • A text box
  • A text label.


This application will:
  • Once you click the toggle button it will change the text in the textbox to a password like text Ie ****=pass
  • Once you click the normal button it will:
  • Check what text is in the textbox then:
  • Change the text in the text label according to what is in the textbox.



As you can see nothing fancy but it should help some people get started into android development.

What an android application is:
  • A mobile software application developed for use on devices powered by Google's Android platform.
  • This can be anything from a game to a calculator and so on.......



NOTE:
I will not be posting loads of pictures. Instead I will use the printscreen application on my computer and I will post the link for you to view if you wish. This makes it allot faster for me to make this tutorial.

Difficulty: Not hard at all
2/10 Depending on if you know a little about java or not.


1st off what your going to need:

  1. Start Eclipse, then select Help > Install New Software.
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    Code:
    https://dl-ssl.google.com/android/eclipse/
  4. Print screen of what it should look like:Screenshot by Lightshot
  5. Click OK.
  6. If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https"
  7. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  8. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  9. Accept the license agreements, then click Finish.
  10. Once the installation completes, restart Eclipse.



And your done you should now be able to start making android applications Via though eclipse

What I wont be showing you is how to setup the android emulator as I've not set it up my self. I just use my Android phone instead.
Anyway on with the Tutorial:

Part 1: Setting up the project folder
If this is your 1st time ever starting up eclipse your going to be a bit puzzled at all the features but do not worry you wont be using most of them
Well with any project you will 1st have to start a new project(obviously lol).
The way I do it is:
  1. Right click on the project explore(The left panel) This should be blank for the moment.
  2. Hover over > new > then click other. Printscreen: Screenshot by Lightshot
  3. Once you clicked other a wizard will pop up asking you which type of project you would like to create. In the wizard click the android folder and choice the option Android application project. Printscreen: Screenshot by Lightshot
  4. On the next screen it will ask you for a project/application/package name you should understand what these mean as the names say what they are If you don't just copy what I've got Printscreen: Screenshot by Lightshot
  5. From here on just keep clicking next until you can click finish.
  6. Once you have clicked finish you will see your project folder in the project explorer to the left Printscreen:Screenshot by Lightshot



Part 2: Setting up the layout
This is the boring part and I really don't even want to explain this as its so easy and you should be able to understand what it means just from what each line says.
So I'm not going to lol
I will just post the code and you can copy and paste but if you would like to know then ask and I would be happy to explain it to you.
  • Anyway open up the folder called: layout
  • and open the file named: activity_main.xml Printscreen: Screenshot by Lightshot
    NOTE: Your file may not have that name. Just open the only XML file in that folder.
  • Once it opens make sure you are in XML view by clicking the file_name.xml Next to the graphical layout at the bottom. Printscreen: Screenshot by Lightshot
  • Copy and paste this code into it:

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:padding="25dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/etCommands" 
    android:hint="Type A Command"
    android:password="true"
   />

<LinearLayout     
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="100" >
    
 <Button android:text="I'm a button! Click me lol!" 
    android:layout_weight="20"
    android:id="@+id/bResults"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
<ToggleButton
    android:paddingTop="8dp"
     android:layout_weight="80"
     android:id="@+id/tbPassword"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="ToggleButton" 
     android:checked="true"/>

    </LinearLayout> 
    
     <TextView android:text="Invalid" 
     android:id="@+id/tvResults"
     android:gravity="center"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     />
 

</LinearLayout>
If you now click on the graphical layout you will now see what it will look like on a mobile screen. Printscreen: Screenshot by Lightshot
If yours looks like that then you have did it correctly

Part 3: On with the java
I will post the code with comments all the way though it saying what each line dose:
Code:
package com.example.rune_server_tut; //PACKAGE NAME.....

//CLASSES THAT WE WILL BE USING
import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.text.InputType;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

//public class means any other class can use it
//MainActivity is the class name
//extends Activity means we will use some methods from the activity class
//implements .......... Means we will use all methods from that class
//Not going to explain fully just use google for full deff
public class MainActivity extends Activity implements View.OnClickListener {

	Button button; //Creates a new variable 
	ToggleButton togButton; //Creates a new variable 
	EditText input;//Creates a new variable 
	TextView display;//Creates a new variable 
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);//Sets the screen view to the activity_main.xml 
		getXmlVaribles(); //gets the xml variables defined below
		togButton.setOnClickListener(this);//checks if the toggle button is clicked
		button.setOnClickListener(this);//checks if the button is clicked
	}
    private void getXmlVaribles() {
		button = (Button) findViewById(R.id.bGetResults);//gets the id of the button
		togButton = (ToggleButton) findViewById(R.id.tbToggle);//gets the id of the toggle button
		input = (EditText) findViewById(R.id.etCommands);//gets the id of the command textbox
		display = (TextView) findViewById(R.id.tvResults);//gets the id of the results textbox
	}    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
	public void onClick(View v) {//Once clicked
		switch (v.getId()) { //If what it clicks id is =
		case R.id.tbToggle: //If id is the togglebutton
			if (togButton.isChecked()) { //if its checked
				input.setInputType(InputType.TYPE_CLASS_TEXT 
						| InputType.TYPE_TEXT_VARIATION_PASSWORD);
				//change type of text to *********
			} else {   //otherwise do this
				//change text type to normal
				input.setInputType(InputType.TYPE_CLASS_TEXT);
			}
			break; //end statement for the togglebutton
		case R.id.bGetResults: //if id is the normal button
			String check = input.getText().toString(); //change textbox data into a string
			display.setText(check); 
			if (check.contentEquals("left")) { //if text in box = left
				display.setGravity(Gravity.LEFT); //change text label results location to the left
			} else if (check.contentEquals("center")) {//if text in box = center
				display.setGravity(Gravity.CENTER);//change text label results location to the center
			} else if (check.contentEquals("right")) {//if the text in box = right
				display.setGravity(Gravity.RIGHT);//change text label results location to the right
			} else if (check.contentEquals("blue")) {//if the text in the box = blue
				display.setTextColor(Color.BLUE); //change text label colour to blue
			} else if (check.contentEquals("random")) {//if the text in the box = random
					Random crazy = new Random(); //Creates a new variable which is random
					display.setText("MADNESS :D"); //sets the text to madness :d
					display.setTextSize(crazy.nextInt(75));//randomly change text size
					display.setTextColor(Color.rgb(crazy.nextInt(265),crazy.nextInt(265),crazy.nextInt(265)));
					//randomly changes text color
					switch(crazy.nextInt(3)) { 
					case 0://random number = 0
						display.setGravity(Gravity.LEFT);  //change text label location to the left
						break;
					case 1:
						display.setGravity(Gravity.CENTER); //change text label location to the center
						break;
					case 2:
						display.setGravity(Gravity.RIGHT);//change text label location to the right
						break;
					}
			} else {//if the textbox dose not contain any of what we have defined then :
				display.setText("INVALID"); //text in the label = INVALID
				display.setGravity(Gravity.CENTER); //Center the label text
			}
			break;
		}
	}
}
Well that's about it I would make a video and show what it exactly dose but I don't see the need for it tbh lol Can't really see anyone actually making this application. This tutorial is more for understanding some of the text methods that are available to you when you are making an Android application.

Hope some of you learnt something this
Any help just post and I will try to help