You are on page 1of 97

Mobile Computing & Application Development [3360704]

EXPERIMENT:- 1

AIM:- Create “Hello World” application. That will display “Hello World”
in the middle of the screen in the red color with white background.

PROGRAM CODE:-

XML File:-

 Activity_main.xml
<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"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff0000"
android:text="@string/hello_world" />
</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.main_pr1;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {


@Override

protected void onCreate(Bundle savedInstanceState)


{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.main_pr1"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.main_pr1.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 2

AIM:- Create application for demonstration of android activity life cycle.

PROGRAM CODE:-

XML File:-

 Activity_main.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.activitylifecycle;

import android.os.Bundle;
import android.widget.Toast;
import android.app.Activity;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(), "onCreate Method Invoked",
Toast.LENGTH_LONG).show();
}

@Override
protected void onStart() {
super.onStart();
Toast.makeText(getApplicationContext(), "onStart Method Invoked",
Toast.LENGTH_LONG).show();
}

@Override
protected void onResume() {
super.onResume();

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

Toast.makeText(getApplicationContext(), "onResume Method Invoked",


Toast.LENGTH_LONG).show();
}

@Override
protected void onPause() {
super.onPause();
Toast.makeText(getApplicationContext(), "onPause Method Invoked",
Toast.LENGTH_LONG).show(); }

@Override
protected void onStop() {
super.onStop();
Toast.makeText(getApplicationContext(), "onStop Method Invoked",
Toast.LENGTH_LONG).show(); }

@Override
protected void onRestart() {
super.onRestart();
Toast.makeText(getApplicationContext(), "onRestart Method Invoked",
Toast.LENGTH_LONG).show(); }

@Override
protected void onDestroy() {
super.onDestroy();
Toast.makeText(getApplicationContext(), "onDestroy Method Invoked",
Toast.LENGTH_LONG).show(); }
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.activitylifecycle"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.activitylifecycle.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 3

AIM:- Create Registration page to demonstration of Basic widgets


available in android.

PROGRAM CODE:-

XML File:-

 Activity_main.xml

<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:id="@+id/txt_welcome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_horizontal"
android:text="CODEX REGISTRATION"
android:textColor="#ffffff"
android:textSize="20dp" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="15dip"
android:background="#cccccc"
android:orientation="vertical" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:text="Name:"
android:textColor="#000000"
android:textSize="15dip" />

<EditText
android:id="@+id/ext_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:text="Phone:"
android:textColor="#000000"
android:textSize="15dip" />

<EditText
android:id="@+id/ext_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dip"
android:layout_margin="10dip"
android:orientation="horizontal" >

<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:text="Gender:"
android:textColor="#000000"
android:textSize="15dip" />

<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:orientation="horizontal" >

<RadioButton
android:id="@+id/rb_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:textColor="#000000" >
</RadioButton>

<RadioButton
android:id="@+id/rb_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:textColor="#000000" >
</RadioButton>
</RadioGroup>
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_height="wrap_content"
android:layout_margin="10dip"
android:orientation="horizontal" >

<TextView
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Area of interest:"
android:textColor="#000000"
android:textSize="15dip" />
</LinearLayout>

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:orientation="horizontal" >

<CheckBox
android:id="@+id/ch_java"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Java"
android:textColor="#000000" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<CheckBox
android:id="@+id/ch_php"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Php"
android:textColor="#000000" />

<CheckBox
android:id="@+id/ch_android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="Android"
android:textColor="#000000" />
</LinearLayout>

<Button
android:id="@+id/btn_register"
android:layout_height="40dip"
android:layout_width="fill_parent"
android:layout_margin="10dip"
android:background="#aaaaaa"
android:text="Register now FREE"/>
</LinearLayout>

</LinearLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.registrationmodule;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.registrationmodule"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<activity
android:name="com.example.registrationmodule.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 4

AIM:- Create an application to call specific entered number by user in the


Edit Text.

PROGRAM CODE:-

XML File:-

 Activity_main.xml

<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity" >

<EditText
android:id="@+id/edt_get_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter Phone Number"
android:inputType="number" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:id="@+id/btn_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Call" />

</LinearLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.callthrougheditview;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

EditText edt_get_number;
Button btn_call;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

edt_get_number=(EditText)findViewById(R.id.edt_get_number);
btn_call=(Button)findViewById(R.id.btn_call);
btn_call.setOnClickListener(new OnClickListener() {

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

@Override
public void onClick(View arg0) {
try {
String Number=edt_get_number.getText().toString();
Intent i=new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("tel:"+Number));
startActivity(i);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.callthrougheditview"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.CALL_PHONE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.callthrougheditview.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 5

AIM:- Create application to open browser with any URL(on button click).

PROGRAM CODE:-

XML File:-

 Activity_main.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="secondactivity"
android:layout_margin="20dp"
android:padding="10dp"
android:text="Click for open google" />
</RelativeLayout>
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.mainpr5;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void secondactivity(View v)


{
Intent intent=new
Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.google.com"));
startActivity(intent);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mainpr5"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.mainpr5.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 6

AIM:- Create simple app to navigate from one screen (activity) to another
screen (activity).

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_horizontal_margin"
android:text="@string/hello_world" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:id="@+id/mbtn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mbtn1"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/mbtn1"
android:text="Third" />

<Button
android:id="@+id/mbtn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_marginTop="50dp"
android:text="Second" />

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 activity_second.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Second" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_activity_second" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MainActivity"
android:id="@+id/sbtn1"
android:layout_margin="@dimen/activity_horizontal_margin" />

<Button
android:id="@+id/ssbtn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/sbtn1"
android:layout_below="@+id/sbtn1"
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_marginTop="44dp"
android:text="Third" />

</RelativeLayout>

 activity_thirdactivity.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Thirdactivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_activity_thirdactivity" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MaIN Activity"
android:id="@+id/tbtn1"
android:layout_margin="@dimen/activity_horizontal_margin" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:id="@+id/tbtn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tbtn1"
android:layout_below="@+id/tbtn1"
android:layout_margin="@dimen/activity_horizontal_margin"
android:layout_marginTop="29dp"
android:text="Second" />

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.first;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {

Button btn1;
Button btn2;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1=(Button) findViewById(R.id.mbtn1);
btn2=(Button) findViewById(R.id.mbtn2);
btn1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i=new Intent(MainActivity.this,Second.class);
startActivity(i);
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

}
});
btn2.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i=new Intent(MainActivity.this,Thirdactivity.class);
startActivity(i);
}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 Second.java:-

package com.example.first;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Second extends Activity {


Button btn1;
Button btn2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
btn1=(Button) findViewById(R.id.sbtn1);
btn2=(Button) findViewById(R.id.ssbtn2);
btn1.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {


Intent i=new Intent(Second.this,MainActivity.class);
startActivity(i);
}
});

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

btn2.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i=new Intent(Second.this,Thirdactivity.class);
startActivity(i);
}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 Thirdactivity.java

package com.example.first;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Thirdactivity extends Activity {


Button btn1;
Button btn2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_thirdactivity);
btn1=(Button) findViewById(R.id.tbtn1);
btn2=(Button) findViewById(R.id.tbtn2);

btn1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i=new Intent(Thirdactivity.this,MainActivity.class);
startActivity(i);
}
});

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

btn2.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent i=new Intent(Thirdactivity.this,Second.class);
startActivity(i);
}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.first"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.example.first.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.first.Second"
android:label="@string/title_activity_second"/ >
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<activity
android:name="com.example.first.Thirdactivity"
android:label="@string/title_activity_thirdactivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 7

AIM:- Create an application that will pass two number using TextView to
the next screen , and on the next screen display sum of that number.

PROGRAM CODE:-

XML File:-

 Activity_main.xml
<LinearLayout
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"
android:orientation="vertical"
tools:context=".MainActivity" >

<EditText
android:id="@+id/edt_num1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter first number" />

<EditText
android:id="@+id/edt_num2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter second number" />
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:id="@+id/btn_sum"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Answer of two number" />
</LinearLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 activity_answer.xml

<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"
tools:context=".AnswerActivity" >

<TextView
android:id="@+id/txt_ans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="answer" />

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.sumofnumber;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

EditText edt_num1, edt_num2;


Button btn_sum;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

edt_num1 = (EditText) findViewById(R.id.edt_num1);


edt_num2 = (EditText) findViewById(R.id.edt_num2);

btn_sum = (Button) findViewById(R.id.btn_sum);


btn_sum.setOnClickListener(new OnClickListener() {

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

@Override
public void onClick(View arg0) {

String num1 = edt_num1.getText().toString();


String num2 = edt_num2.getText().toString();

Intent i = new Intent(MainActivity.this, AnswerActivity.class);


i.putExtra("num1", num1);
i.putExtra("num2", num2);
startActivity(i);

}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 AnswerActivity.java

package com.example.sumofnumber;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class AnswerActivity extends Activity {

TextView txt_ans;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_answer);

txt_ans = (TextView) findViewById(R.id.txt_ans);


Intent i = getIntent();
int num1 = Integer.parseInt(i.getStringExtra("num1"));
int num2 = Integer.parseInt(i.getStringExtra("num2"));

txt_ans.setText("Addition of two number is:" + (num1 + num2));


}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sumofnumber"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.sumofnumber.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.sumofnumber.AnswerActivity"
android:label="@string/title_activity_answer" />
</application>
</manifest>
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 8

AIM:- Create an application for demonstration of Relative in android.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
tools:context=".MainActivity" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Button" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_below="@+id/button2"
android:layout_marginTop="20dp"
android:text="Button" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:text="Button" />
</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.relativedemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.relativedemo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.example.relativedemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 9

AIM:- Create an application for demonstration of Table Layout in


android.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<TableLayout
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"
android:shrinkColumns="*"
android:stretchColumns="*"
tools:context=".MainActivity" >

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_span="2"
android:text="Button1" />
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button2" />

</TableRow>

<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button3" />

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button4" />

<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Button5" />

</TableRow>

</TableLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.tableviewdemo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tableviewdemo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name="com.example.tableviewdemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 10

AIM:- Create an application that will Demonstrate Button onClick() Event


and change the TextView Color based on button Clicked.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:id="@+id/txtcolor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!"/>

<EditText
android:layout_width="match_parent"
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_height="wrap_content"
android:layout_margin="20dp"
android:id="@+id/etcolor"
android:maxLength="10"
android:hint="Enter #code of color"
android:padding="10dp" />

<Button
android:id="@+id/btncolor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/etcolor"
android:layout_below="@+id/etcolor"
android:layout_margin="20dp"
android:layout_marginTop="125dp"
android:onClick="secondactivity"
android:padding="10dp"
android:text="Change Color" />

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.mainpr9;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {


EditText etcolor;
TextView txtcolor;
String color;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

public void secondactivity(View V)


{
etcolor=(EditText) findViewById(R.id.etcolor);
txtcolor=(TextView) findViewById(R.id.txtcolor);
color=etcolor.getText().toString();
txtcolor.setTextColor(Color.parseColor(color));
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mainpr9"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.mainpr9.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 11

AIM:- Create an UI such that, one screen have list of all the types of cars.
On selecting of any car name, next screen should show Car details
like : name, launched date, company name.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<LinearLayout 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"
tools:context=".MainActivity" >

<ListView
android:id="@+id/lv_car"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/ >
</LinearLayout>

 car_details.xml

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

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CarDetail" >

<TextView
android:id="@+id/txt_carname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Car Name"
android:textSize="25dip" />

<ImageView
android:id="@+id/car_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal" />

<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Launch Date:"
android:textStyle="bold" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<TextView
android:id="@+id/txt_launch_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="00-00-0000" />
</LinearLayout>

<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Price:"
android:textStyle="bold" />

<TextView
android:id="@+id/txt_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="3L Rs/-" />
</LinearLayout>
</LinearLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.carlistview;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {

ListView lv_car;
String[] cars = new String[] { "BMW-i8", "Hyundai New Sonata",
"Honda New Jazz", "Audi TT Roadster", "Ford New Figo" };
String[] launched_date = new String[] { "01-01-2015", "01-02-2015",
"01-03-2015", "01-04-2015", "01-05-2015" };
String[] price = new String[] { "10,000", "20,000", "30,000", "40,000",
"50,000" };
String[] images = new String[] { "bmw_i8", "hyundai_new_sonata",
"honda_new_jazz", "audi_tt_roadster", "ford_new_figo" };

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(


getApplicationContext(), android.R.layout.simple_list_item_1,
android.R.id.text1, cars);

lv_car = (ListView) findViewById(R.id.lv_car);


lv_car.setBackgroundColor(Color.BLACK);
lv_car.setAdapter(adapter);

lv_car.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int selected, long arg3) ;
// TODO Auto-generated method stub
Intent i = new Intent(MainActivity.this, CarDetail.class);
i.putExtra("cars", cars[selected]);
i.putExtra("launched_date", launched_date[selected]);
i.putExtra("price", price[selected]);
i.putExtra("images", images[selected]);
startActivity(i);
}
});
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 Car_Details.java

package com.example.carlistview;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class CarDetail extends Activity {

TextView txt_carname, txt_launch_date, txt_price;


ImageView car_image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.car_detail);
txt_carname = (TextView) findViewById(R.id.txt_carname);
txt_launch_date = (TextView) findViewById(R.id.txt_launch_date);
txt_price = (TextView) findViewById(R.id.txt_price);
car_image = (ImageView) findViewById(R.id.car_image);

Intent i = getIntent();
String carname = i.getStringExtra("cars");
String launched_date = i.getStringExtra("launched_date");
String price = i.getStringExtra("price");
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

String image = i.getStringExtra("images");


txt_carname.setText(carname);
txt_launch_date.setText(launched_date);
txt_price.setText(price);

try {
int id = getResources().getIdentifier(image, "drawable",
getPackageName());
Drawable d = getResources().getDrawable(id);
car_image.setImageDrawable(d);
} catch (NotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.carlistview"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.carlistview.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.carlistview.CarDetail"
android:label="@string/title_activity_car_detail" />
</application>
</manifest>
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 12

AIM:- Create an application for demonstration of Scroll view in android.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
tools:context=".MainActivity" >

<ScrollView
android:id="@+id/sv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<ImageView
android:src="@drawable/go"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ImageView
android:src="@drawable/images"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ImageView
android:src="@drawable/diff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.registrationmodule;

import android.os.Bundle;
import android.app.Activity;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.registrationmodule "
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.registrationmodule.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 13

AIM:- Create spinner with strings taken from resource folder(res >> value
folder). On changing spinner value, change background of screen.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
tools:context=".MainActivity" >

<Spinner
android:id="@+id/spn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/color"
android:prompt="@string/hello_world"/>
</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

 strings.xml

<?xml version="1.0" encoding="utf-8"?>


<resources>
<string name="app_name">SpinnerDemo</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>

<string-array name="color">
<item>GREEN</item>
<item>BLUE</item>
<item>BLACK</item>
</string-array>
</resources>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.spinnerdemo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.RelativeLayout;
import android.widget.Spinner;

public class MainActivity extends Activity {

RelativeLayout relative;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

relative = (RelativeLayout) findViewById(R.id.relative);


Spinner spn = (Spinner) findViewById(R.id.spn);

spn.setOnItemSelectedListener(new OnItemSelectedListener() {

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
switch (arg2) {
case 0:
relative.setBackgroundColor(Color.GREEN);
break;
case 1:
relative.setBackgroundColor(Color.BLUE);
break;
case 2:
relative.setBackgroundColor(Color.BLACK);
break;
default:
break;
}
}

@Override
public void onNothingSelected(AdapterView<?> arg0) { } });
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spinnerdemo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.spinnerdemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 14

AIM:- Create an application that will get the Text Entered in Edit Text
and display that Text using Custom Toast(message) With Duration.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
tools:context=".MainActivity" >

<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="106dp"
android:hint="Enter Message..."
android:ems="10" />

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="26dp"
android:onClick="display"
android:text="Display" />
</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.toastfromeditview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {


Button button1;
EditText edt_msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

edt_msg = (EditText) findViewById(R.id.editText1);


button1=(Button) findViewById(R.id.button1);
}
public void display(View v){
super.onResume();
String str=edt_msg.getText().toString();
Toast.makeText(getApplicationContext(),str,Toast.LENGTH_LONG).show();
}
}
Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.toastfromeditview"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.toastfromeditview.MainActivity "
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

EXPERIMENT:- 15

AIM:- Create an application that will Demonstrate Dialog Box Control In


Android.

PROGRAM CODE:-

XML File:-

 activity_main.xml

<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

</RelativeLayout>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

JAVA File:-

 MainActivity.java

package com.example.pr15;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AlertDialog.Builder ad=new AlertDialog.Builder(this);
ad.setTitle("About MCA Object");
ad.setMessage("Do You Like MCA Subject??");
ad.setPositiveButton("Yes",new OnClickListener(){
public void onClick(DialogInterface dialog,int arg0){
Toast.makeText(getApplicationContext(), "I Would Like MCA Subject",
Toast.LENGTH_LONG).show();
}});
ad.setNegativeButton("No",new OnClickListener(){
public void onClick(DialogInterface dialog,int arg0) {
Toast.makeText(getApplicationContext(), "I Couldn't Like MCA Subject",
Toast.LENGTH_LONG).show();

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

}});
ad.setNeutralButton("Don't Decide",new OnClickListener(){
public void onClick(DialogInterface dialog,int arg0) {
Toast.makeText(getApplicationContext(), "I am Confuse!! ",
Toast.LENGTH_LONG).show();
}});
ad.show();
}
}

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

MANIFEST File:-

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pr15"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.pr15.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-


Mobile Computing & Application Development [3360704]

OUTPUT:-

Vision:-
“To mould technocrat in the field of computer engineering with innovation skills, moral values & societal concerns.”

Tapi Diploma Engg. College, Surat. Page No.:-

You might also like