This blog is a step-by-step guide in building your first android application.
0.1.
Install JDK
Install JDK via the following link :
http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html
Extract the contents of the ZIP file
0.1.
Install Eclipse
Install Eclipse via the following link :
http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigor
> Download the ZIP file to your local folder
> Extract the contents of the ZIP file
> Double-click on eclipse.exe to start the eclipse
> Enter the folder for the Workspace, and click OK
* </p><ul><li>Install the Android SDK</li></ul><p>Install the SDK via the following link :</p><p> [http://developer.android.com/sdk/index.html | http://developer.android.com/sdk/index.html]</p><p> </p><ul><li>Install Eclipse ADT(Android Development Tools) Plug-In*
> Start Eclipse
> Click on Help -> Install New Software
> Click "Add" in the right corner
> In the "Add Repository" dialog, enter the path as shown below, and click OK
> Select the "Check Box" against "Developer Tools" and click "Next"
> In the next window, you'll see a list of the tools to be downloaded.
>
Click Next.
>
Click Finish.
> When the installation completes, restart Eclipse.
Configure ADT Plug-In > Start Eclipse
> Select Window -> Preferences
> Select "Android" from the left panel, enter the downloaded SDK location and click "Apply" and then "OK"
0.1.
Configure the Android Simulator > Start Eclipse
> Click on Window -> Android SDK and AVD Manager
> Select "Virtual Devices" in the left panel and click on "New"
> In the dialog , enter as shown below
0.1.
Test your configuration by writing a simple application > Start Eclipse
> Click on New -> Project
> Select "Android Project" and click on "Next"
> Enter the attributes of the project and click "Finish"
> The project "myFirstApplication" will show the nodes as shown below
> Double-Click on AndroidManifest.xml
> Click on the tab "Instrumentation", and then "Add"
> Select "Instrumentation" in the dialog
> Click on "Browse" against the name
> Wait for the system to find a matching runner, and then select the matching item, and click OK
> Select the package, and then click on "Save"
* Now lets write a simple application to display a text , on click of a button</p><p> > Lets add a button and a Textbox in the layout</p><p> > Click on "Main.XML", and modify the XML as shown below</p><p>!https://weblogs.sdn.sap.com/weblogs/images/33546/Main.PNG|height=227|alt=image|width=192|src=https:/...!</p><p>*XML Layout **********************************************</p><p><?xml version="1.0" encoding="utf-8"?><br /><LinearLayout xmlns:android="[http://schemas.android.com/apk/res/android | http://schemas.android.com/apk/res/android]"<br /> android:orientation="vertical"<br /> android:layout_width="fill_parent"<br /> android:layout_height="fill_parent"<br /> ><br /><TextView <br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content" <br /> android:text="Hi Android"<br /> /> <br /><TextView <br /> android:id="@id/result" <br /> android:layout_width="fill_parent" <br /> android:layout_height="wrap_content" <br /> android:text=""</p><p> /><br /><Button <br /> android:text="Display Text" <br /> android:id="@id/button_text" <br /> android:layout_width="wrap_content" <br /> android:layout_height="wrap_content"><br /> </Button> <br /></LinearLayout></p><p>************************************************************
** Note that the name of the text view is "result" and name of the button is "button_text"
Lets go back and write some code to finish our application
> Click on "myFirstApplicationActivity" and write the following code :
Start of Code **********************************************</p><p>package myFirstApplication.com;<br />import android.app.Activity;<br />import android.os.Bundle;<br />import android.view.;
import android.widget.Button;
import android.widget.TextView;
public class MyFirstApplicationActivity extends Activity {
private TextView result;
/** Called when the activity is first created. /<br /> @Override<br /> public void onCreate(Bundle savedInstanceState) {<br /> super.onCreate(savedInstanceState);<br /> setContentView(R.layout.main);<br /> result = (TextView)findViewById(R.id.result);<br /> Button button_text = (Button)findViewById(R.id.button_text);<br /> button_text.setOnClickListener(new Button.OnClickListener() <br /> { <br /> public void onClick (View v)<br /> { <br /> display_text(); <br /> }<br /> }<br /> ); <br /> }<br /> public void display_text()<br /> {<br /> result.setText("[www.sap.com | http://www.sap.com]");</p><p> } <br />}</p><p>**************************************************************
****************************************************************
> Run the application by clicking on "Run" in the menu bar and then select "Android Application" in the dialog
> Wait for a few seconds until , we see the following screen :
Wait for about 40-60 secs to see your application, then click on the home in the right hand side, or unlock the application
Here it is !!! "myFirstApplication".
Click on "myFirstApplication".
Click on the button "Display Text" to see the text www.sap.com (http://www.sap.com).