0% found this document useful (0 votes)
8 views43 pages

Mobile Application Developement Lab

This document outlines the Mobile Application Development Lab for the Bachelor of Computer Applications program at Dwaraka Doss Goverdhan Doss Vaishnav Evening College. It includes a record of practical exercises, code examples, and results for various Android application components such as TextView, Button, EditText, ToggleButton, and RadioButton. Each exercise is designed to help students learn and verify their understanding of mobile application development concepts during the academic year 2020-2021.

Uploaded by

Lokesh Rajasekar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views43 pages

Mobile Application Developement Lab

This document outlines the Mobile Application Development Lab for the Bachelor of Computer Applications program at Dwaraka Doss Goverdhan Doss Vaishnav Evening College. It includes a record of practical exercises, code examples, and results for various Android application components such as TextView, Button, EditText, ToggleButton, and RadioButton. Each exercise is designed to help students learn and verify their understanding of mobile application development concepts during the academic year 2020-2021.

Uploaded by

Lokesh Rajasekar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DWARAKA DOSS GOVERDHAN DOSS VAISHNAV

EVENING COLLEGE (AUTONOMOUS)


ARUMBAKKAM, CHENNAI-600 106

DEPARTMENT OF COMPUTER APPLICATIONS

Bachelor of Computer Applications

MOBILE APPLICATION DEVELOPMENT LAB

NAME: _____________________________________
REGISTER NUMBER: _______________________
CLASS: III B.C.A
SECTION:
DWARAKA DOSS GOVERDHAN DOSS VAISHNAV
EVENING COLLEGE (AUTONOMOUS)
ARUMBAKKAM, CHENNAI-600 106

DEPARTMENT OF COMPUTER APPLICATIONS

MOBILE APPLICATION DEVELOPMENT LAB

Certified that this is a record work done by ………………………………


whose Register no. ………………………. of III B.C.A, during the
academic Year 2020 – 2021.

Faculty In-charge Head of the Department

Submitted for practical examination held on ………………………………... at


Dwaraka Doss Goverdhan Doss Vaishnav College, Chennai-106

Internal Examiner External Examiner


CONTENT

[Link]. DATE PROGRAM [Link] SIGN

1 ACTIVITY WITHOUT TITLE BAR 1

2 TEXTVIEW CONTROL 3

COUNTERS USING BUTTON


3 5
CONTROLS
CHANGING FONT SIZE AND COLOR
4 9
USING BUTTON CONTROL

5 EDIT TEXT CONTROL 13

6 TOOGLE BUTTON CONTROL 15

7 RADIO BUTTON CONTROL 18

AUTOCOMPLETE TEXT VIEW


8
CONTROL

9 CHECK BOX CONTROL

10 SEEKBAR CONTROL

11 DATE PICKER VIEW

12 TIME PICKER VIEW

13 LIST VIEW

14 IMAGE BUTTON CONTROL

15 IMAGE VIEW
[Link]: 1

DATE:
ACTIVITY WITHOUT TITLE BAR

[Link]

package [Link];

import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity


{
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView([Link].activity_main);
}
}

1
OUTPUT:

RESULT:

Hence the Program is successfully verified.

2
[Link]: 2

DATE:

TEXTVIEW CONTROL

LAYOUT: Place a textview widget

[Link]

package [Link];

import [Link];
import [Link].*;
import [Link];

public class MainActivity extends Activity


{
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
tv = (TextView)findViewById([Link].textView1);
[Link]("Welcome to Android Programming. All the Best");
}
}

3
OUTPUT:

RESULT:

Hence the Program is successfully verified.

4
[Link]: 3

DATE:

COUNTER USING BUTTON CONTROL

NOTE: Place two buttons and a textview control

activity_main.xml

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="106dp"
android:layout_marginTop="65dp"
android:layout_marginEnd="69dp"
android:layout_marginBottom="308dp"
android:text="-1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/textView" />

<TextView
android:id="@+id/textView"
android:layout_width="183dp"
android:layout_height="68dp"
android:layout_marginStart="114dp"
android:layout_marginTop="242dp"
android:layout_marginEnd="114dp"
android:layout_marginBottom="421dp"
android:text="TextView"
android:textColor="#FF5722"
android:textSize="36sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginTop="65dp"
android:layout_marginEnd="106dp"
android:layout_marginBottom="308dp"
android:background="#E91E63"
android:text="+1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/button2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />

5
[Link]

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ int count=0;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
final TextView tv=(TextView)findViewById([Link]);
Button b1=(Button)findViewById([Link]);
Button b2=(Button)findViewById([Link].button2);
[Link](new OnClickListener()
{ public void onClick(View v)
{ count++;
[Link]("Count="+count);
}
});
[Link](new OnClickListener()
{ public void onClick(View v)
{
count--;
[Link]("Count="+count);
}
});
}
}

6
OUTPUT:

INCREMENT BY 1

7
DECREMENT BY 1

RESULT:

Hence the Program is successfully verified.

8
[Link]: 4

DATE:

CHANGING FONT SIZE AND COLOR USIGN BUTTON CONTROL

NOTE: Place two buttons and a textview control

activity_main.xml

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/hello_world"
android:textStyle="bold" />

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_margin="20dp"
android:layout_marginTop="68dp"
android:gravity="center"
android:text="Change color"
android:textSize="25sp" />

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_margin="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="Change font size"
android:textSize="25sp" />

[Link]

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

9
public class MainActivity extends Activity
{ int ch=0;
int font=30;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
final TextView t= (TextView) findViewById([Link].textView1);
Button b1= (Button) findViewById([Link].button1);
[Link](new [Link]()
{ @Override
public void onClick(View v)
{
[Link](font);
font = font + 5;
if (font == 50)
font = 30;
}
});
Button b2= (Button) findViewById([Link].button2);
[Link](new [Link]()
{ @Override

public void onClick(View v)


{ ch++;
if (ch == 7)
ch = 1;
switch (ch)
{
case 1: [Link]([Link]); break;
case 2: [Link]([Link]); break;
case 3: [Link]([Link]); break;
case 4: [Link]([Link]); break;
case 5: [Link]([Link]); break;
case 6: [Link]([Link]); break;
}
}
});
}
}

10
OUTPUT:

FONT SIZE:

11
FONT COLOR:

RESULT:

Hence the Program is successfully verified.

12
[Link]: 5
DATE:

EDITTEXT

NOTE: Place a textview, an edittext and button.

activity_main.xml

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="110dp"
android:layout_marginTop="51dp"
android:text="Give ur Name"
android:textAppearance="?android:attr/textAppearanceSmall" />

<EditText
android:id="@+id/et1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp"
android:ems="10" />

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/et1"
android:layout_centerHorizontal="true"
android:layout_marginTop="56dp"
android:onClick="show"
android:text="Submit" />

[Link]

import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity


{
Button b;
EditText t;
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);

13
b=(Button)findViewById([Link].b1);
t=(EditText)findViewById([Link].et1);
}
public void show(View v)
{
[Link](getApplicationContext(),"Welcome
"+[Link](),Toast.LENGTH_LONG).show();
}
}

OUTPUT:

RESULT:

Hence the Program is successfully verified.


14
[Link]: 6
DATE:

TOGGLEBUTTON

NOTE: Place two togglebuttons and a button.

activity_main.xml

<TableRow >
<ToggleButton
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginTop="38dp"
android:drawableRight="@drawable/ic_launcher"
android:text="TOGGLE1" />
</TableRow>
<TableRow >
<ToggleButton
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginTop="38dp"
android:drawableLeft="@drawable/ic_launcher"
android:text="TOGGLE2"
android:textColor="#000" />
</TableRow>
<TableRow>
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/t1"
android:layout_weight="4.65"
android:onClick="click"
android:text="SUBMIT" />
</TableRow>

[Link]

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends Activity


{ ToggleButton tb1,tb2;

15
Button b;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
tb1=(ToggleButton)findViewById([Link].t1);
tb2=(ToggleButton)findViewById([Link].t2);
b=(Button)findViewById([Link].b1);
}
public void click(View v)
{
String status = "ToggleButton1 : " + [Link]() + "\n" + "ToggleButton2 : " +
[Link]();
[Link](getApplicationContext(), status,
Toast.LENGTH_SHORT).show(); // display the current state of toggle button's
}
}

16
OUTPUT:

RESULT:

Hence the Program is successfully verified.

17
[Link]: 7

DATE:

RADIOBUTTON

NOTE: Place a textview, a button and a radiogroup with 3 radiobuttons.

activity_main.xml
<TableRow>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Enter ur hobby" />
</TableRow>
<TableRow>
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Reading Books" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Listening Songs" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gardening" />
</RadioGroup>
</TableRow>
<TableRow>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/textView1"
android:layout_marginBottom="78dp"
android:layout_marginRight="35dp"
android:onClick="show"
android:text="SUBMIT UR HOBBY" >
</Button>
</TableRow>

18
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ RadioGroup rg;
RadioButton rb0,rb1,rb2;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
rg=(RadioGroup)findViewById([Link].radioGroup1);
rb0=(RadioButton)findViewById([Link].radio0);
rb1=(RadioButton)findViewById([Link].radio1);
rb2=(RadioButton)findViewById([Link].radio2);
b=(Button)findViewById([Link].button1);
}
public void show(View v)
{ if ([Link]())
[Link](getApplicationContext(), "Your Hobby is
"+[Link]().toString(), Toast.LENGTH_LONG).show();
else if ([Link]())
[Link](getApplicationContext(), "Your Hobby is
"+[Link]().toString(), Toast.LENGTH_LONG).show();
else
if ([Link]())
[Link](getApplicationContext(), "Your Hobby is
"+[Link]().toString(), Toast.LENGTH_LONG).show();
}
}
(or)
public void show(View v)
{ int id=[Link]();
rb=(RadioButton)findViewById(id);
[Link](getApplicationContext(), "Your Hobby is "+[Link](),
Toast.LENGTH_LONG).show();
}

19
OUTPUT:

RESULT:

Hence the Program is successfully verified.

20
[Link]: 8

DATE:

AUTOCOMPLETETEXTVIEW

NOTE: Place an autocompletetextview

activity_main.xml
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="121dp"
android:ems="10"
android:hint="Enter an Indian Language Here">
<requestFocus />
</AutoCompleteTextView>

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ String[] lang = {"Tamil", "Telugu", "Malayalam", "Kannadam", "Urdu", "Hindi","Konkani",
"Marathi","Tulu"};
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
AutoCompleteTextView auto = (AutoCompleteTextView)
findViewById([Link].autoCompleteTextView1);
ArrayAdapter adapter = new
ArrayAdapter(this,[Link].simple_expandable_list_item_1,lang);
[Link](1);//start searching from 1 character
[Link](adapter);
}
}

21
OUTPUT:

RESULT:

Hence the Program is successfully verified.

22
[Link]: 9

DATE:

CHECKBOX CONTROL

NOTE: Place 3 checkboxes and a button

activity_main.xml
<TableRow>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginTop="60dp"
android:layout_toRightOf="@+id/textView1"
android:text="Poori" />
</TableRow>
<TableRow >
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/checkBox1"
android:layout_below="@+id/checkBox1"
android:text="Dosai" />
</TableRow>
<TableRow>
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/checkBox2"
android:layout_below="@+id/checkBox2"
android:text="Coffee" />
</TableRow>
<TableRow>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/checkBox2"
android:layout_below="@+id/checkBox3"
android:layout_marginTop="51dp"
android:onClick="foodorder"
android:text="submit" />
</TableRow>

23
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ CheckBox poori,dosai,coffee;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
poori=(CheckBox)findViewById([Link].checkBox1);
dosai=(CheckBox)findViewById([Link].checkBox2);
coffee=(CheckBox)findViewById([Link].checkBox3);
b1=(Button)findViewById([Link].button1);
}
public void foodorder(View v)
{ int totalamount=0;
StringBuilder result=new StringBuilder();
[Link]("Selected Items");
if([Link]())
{ [Link]("\n Poori 40 Rs");
totalamount+=40;
}
if([Link]())
{ [Link]("\n Dosai 50 Rs");
totalamount+=50;
}
if([Link]())
{ [Link]("\n Pizza 30 Rs");
totalamount+=30;
}
[Link]("\n Total:"+totalamount+"Rs");
[Link](getApplicationContext(), [Link](),
Toast.LENGTH_LONG).show();
}
}

24
OUTPUT:

RESULT:

Hence the Program is successfully verified.

25
[Link]: 10

DATE:

SEEKBAR CONTROL

NOTE: Place 3 seekbars

activity_main.xml
<SeekBar
android:id="@+id/seekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/seekBar1"
android:layout_marginTop="25dp" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/seekBar3"
android:layout_alignTop="@+id/seekBar3"
android:layout_marginTop="86dp" />
<SeekBar
android:id="@+id/seekBar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/seekBar1"
android:layout_marginTop="71dp" />

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity implements OnSeekBarChangeListener
{ SeekBar r,g,b;
RelativeLayout disp;
@Override
protected void onCreate(Bundle savedInstanceState)
{
[Link](savedInstanceState);
setContentView([Link].activity_main);
r=(SeekBar)findViewById([Link].seekBar1);
g=(SeekBar)findViewById([Link].seekBar2);

26
b=(SeekBar)findViewById([Link].seekBar3);
[Link]((OnSeekBarChangeListener) this);
[Link]((OnSeekBarChangeListener) this);
[Link]((OnSeekBarChangeListener) this);
disp=(RelativeLayout)findViewById([Link].layout1);
}

public void onProgressChanged(SeekBar s,int p,boolean b1)


{
[Link]([Link]([Link](), [Link](), [Link]()));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar)
{
// TODO Auto-generated method stub
}
}

27
OUTPUT:

RESULT:

Hence the Program is successfully verified.

28
[Link]: 11

DATE:

DATE PICKER VIEW

NOTE: Place a datepicker view, a textview and a button

activity_main.xml

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="102dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:text="" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Change Date" />
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp" />

29
[Link]

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ DatePicker dp;
Button b;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
tv=(TextView)findViewById([Link].textView1);
dp=(DatePicker)findViewById([Link]);
b=(Button)findViewById([Link].button1);
}

public void click(View view)


{
StringBuilder s=new StringBuilder();;
[Link](([Link]() + 1)+"/");//month is 0 based
[Link]([Link]()+"/");
[Link]([Link]());
[Link]("Change Date: "+s);
}
}

30
OUTPUT:

RESULT:

Hence the Program is successfully verified.

31
[Link]: 12

DATE:

TIME PICKER VIEW

NOTE: Place a timepicker view, a textview and a button

activity_main.xml

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="102dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:text="" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="Change Time" />
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="36dp" />

32
[Link]

package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ TextView tv;
TimePicker tp;
Button b;
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
tv=(TextView)findViewById([Link].textView1);
tp=(TimePicker)findViewById([Link]);
tp.setIs24HourView(true); //true for 24 hour and false for 12 hour
b=(Button)findViewById([Link].button1);
[Link](new [Link]()
{ @Override
public void onClick(View view)
{ String s="Current Time: “+[Link]()+":"+[Link]();
[Link](s);
}
});
}
}

33
OUTPUT:

RESULT:

Hence the Program is successfully verified.

34
[Link]: 13

DATE:

LIST VIEW

NOTE: Place a listview

activity_main.java
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="@android:color/holo_blue_bright" >
</ListView>

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ String [] col= {"red","blue","magenta","gray",”white”};
@Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
ListView lv=(ListView)findViewById([Link].listView1);
[Link]([Link]);
final RelativeLayout r=(RelativeLayout)findViewById([Link].l);
ArrayAdapter<String> a= new
ArrayAdapter<String>(getApplicationContext(),[Link].simple_list_item_1,col);
[Link](a);
[Link](new OnItemClickListener()
{ public void onItemClick(AdapterView a1,View a2,int a3,long a4)
{
[Link](getApplicationContext(), "Backgroundcolor will
change to "+col[a3], Toast.LENGTH_SHORT).show();
if (a3==0)
[Link]([Link]);
else
if (a3==1)
[Link]([Link]);
else
if (a3==2)
[Link]([Link]);
else

35
if (a3==3)
[Link]([Link]);
}
});
}
}

OUTPUT:

RESULT:

Hence the Program is successfully verified.

36
[Link]: 14

DATE:

IMAGE BUTTON CONTROL

NOTE: Place an imagebutton

activity_main.xml
<ImageButton
android:id="@+id/rose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:onClick="show"
android:padding="20dp"
android:src="@drawable/rose1" />

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ @Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
ImageButton i = (ImageButton)findViewById([Link]);
}
public void show(View v)
{
[Link](this,"Rose Button",Toast.LENGTH_LONG).show();
}
}

37
OUTPUT:

RESULT:

Hence the Program is successfully verified.

38
[Link]: 15

DATE:

IMAGEVIEW

NOTE: Place two imageviews

activity_main.xml
<ImageView
android:id="@+id/rose"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:onClick="f1click"
android:scaleType="fitXY"
android:src="@drawable/rose" />
<ImageView
android:id="@+id/sunflower"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:layout_below="@+id/rose"
android:onClick="f2click"
android:scaleType="fitXY"
android:src="@drawable/sunflower" />

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends Activity
{ @Override
protected void onCreate(Bundle savedInstanceState)
{ [Link](savedInstanceState);
setContentView([Link].activity_main);
ImageView f1 = (ImageView) findViewById([Link]);
ImageView f2 = (ImageView) findViewById([Link]);
}
public void f1click(View view)
{[Link](getApplicationContext(), "ROSE", Toast.LENGTH_LONG).show(); }
public void f2click(View view)
{[Link](getApplicationContext(), "SUNFLOWER",
Toast.LENGTH_LONG).show();
}

39
OUTPUT:

RESULT:

Hence the Program is successfully verified.

40

You might also like