Download Sample work on Android application development

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Sample work
on
Android application development
Document Prepared By
Md Aman Ullah Bhuiyan
London, UK
Created
Modified
17.112011
08.01.2012
Email: [email protected]
Mobile: 07427-5961-14
Android Application:
The Environment i used:
•
•
•
•
•
Java ( As, Programming Language)
Java JDK ( Development Kit)
Eclipse (As IDE, Integrated Development Environment)
Android ADT Plugin.
Android SDK ( Software Development Kit)
My Sample work:
•
•
•
•
My sample work for android will look something like below.
It will have two buttons and one display.
One button will increase the value of counter
And another button will decrease the value of counter
The display will show the new value of counter each time it is changing.
Figure: Normal condition.
When you press “Add one” Button
Figure: Value is added by one per click
Figure: Value is added by one, per click
When you press “Subtract one” button
Figure: Value is decreased by one per click
Figure: Value is decreased by one per click
Step by Step Description
Step-1:
One Text view is added:
Graphical view:
main.xml file for upper figure:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" Your Total is 0"
android:textSize="30dp"
android:layout_gravity="center"
android:gravity="center"
/>
</LinearLayout>
Step-2:
When one Text View and two buttons are created
Graphical Layout
main.xml file in this stage
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" Your Total is 0"
android:textSize="30dp"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/tvDisplay"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Add one"
android:layout_gravity="center"
android:gravity="center"
android:textSize="25dp"
android:id="@+id/bAdd"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Subtract One"
android:layout_gravity="center"
android:gravity="center"
android:textSize="25dp"
android:id="@+id/bSub"
/>
</LinearLayout>
Step-3:
Activity.java file = main work and logic
package com.amanbhuiyan;
import
import
import
import
import
android.app.Activity;
android.os.Bundle;
android.view.View;
android.widget.Button;
android.widget.TextView;
public class TheNewBossonActivity extends Activity
{
/** Called when the activity is first created. */
int counter;
Button add,sub;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
counter=0;
add=(Button)findViewById(R.id.bAdd);
sub=(Button)findViewById(R.id.bSub);
display=(TextView)findViewById(R.id.tvDisplay);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0)
{
counter=counter+1;
display.setText(" your total is" + counter);
// TODO Auto-generated method stub
}
});
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0)
{
counter= counter-1;
display.setText(" your total is" + counter);
// TODO Auto-generated method stub
}
});
}
}
Then final output:
see the next page
Apps 2 Sample:
Name:
Twitter Like Application
Xml File: Status .xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="50dp"
android:text="@string/Status_Activity_Text" android:textSize="35dp"
android:layout_gravity="center" android:gravity="center"/>
<EditText
android:id="@+id/Status_Activity_Edit_Text_ID"
android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_weight="1"
android:hint="@string/Status_Activity_Edit_Text_Hint" android:textSize="25dp">
<requestFocus />
</EditText>
<Button
android:id="@+id/Status_Activity_Button_ID"
android:layout_width="240dp"
android:layout_height="80dp"
android:text="@string/Status_Activity_Button_Text"
android:gravity="center" android:layout_gravity="center" android:textSize="30dp"
android:textStyle="bold"/>
</LinearLayout>
Sample Apps Number 3:
Apps Name:
Common Interview Question in JAVA:
Graphical Layout:
Activity 1: Sample
Activity 2:
Activity 3:
Sample XML File for the 3rd Activity:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:gravity="center">
<TextView
android:layout_width="fill_parent"
android:layout_height="25dp"
android:text="@string/FirstActivityFirstText"
android:layout_gravity="center" android:gravity="center" android:textSize="23dp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="90dp"
android:text="@string/ThirdActivitySecondText" android:textSize="18dp"
android:textStyle="bold"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:text="@string/ThirdActivityThirdText" android:layout_weight="1"
android:textSize="20dp"/>
</LinearLayout>
More Update Coming Soon...
===========================
Thank you ...for Watching my
Portfolio
From Aman.
Related documents