Android
Android
Program
Source Code
<resour ces>
</resource s>
activitj-main- m
<Aelativelayout tool :
Contex t -". MainAe tivity "
<Button
android : id
=@+ia/button1"
YRelativelayout>
MainActivity: java
Public cla ss Main Aetiviy exends Aetivity $
Button btn;
22-2-202S
Prgram 2
Source code
strings. xml
Kresour ces>
name 1">First NO
Lotring /sting
</resources>
activity-main,m!
android: id 'etid/tectView2
android: tert ostringl +v2" />
<Button
LTextvie
android :id ="+id /tetView />
3
MainActivity- java
Tectview tiew;
Float ci
Protected
void onCreate CBun dle Savedlnstane Shate)
tview setText
[Link] Ce) :
3
program 3 22- 2- 2025
cresources >
activitymain. eml
CRelativelayous>
LButton
Main
Acivityjava
proteetd void
onCreateCBundle Saved lnstance Sta fe)
btn= CButton)
btn =
setOnclik
findview Byld
Listhe
CiR-id-
Cnew oncick
button1) ;
Listher c) $
public void
onclick (view
argo
Calendar
ce CalendergetIn tance C))
Jear= C-ges [Link]):
bl. Setmessage
C" Curvent
ystem Date is : "tsyslae) i
[Link] Button
Alert Dialog
d
(oine
=b1. cr
[Link] ,
nui)
eate ci
d1-showc);
6
Program 4 22-2-2o25
et Write a to
program Display an ale+ boz with ok and Canel
Source Code
activity [Link]
<Relativeayout>
<Button
android :id = "+id/button1"
MainActivityjova
impleme nts onclickListher
e+ends Activis
public class MainAc tivity
Button b+n
AlertDialog
[Link]);
d4= [Link] c ;
3)
program 5 22- 2- 2025
stringsXmI
cresources>
re/rmenu/main. m
Cmenus
item
android id ="@id
andrbid :+iHe=@stringl eut
/eutlten"
<item
andnod :d
etid/google
android :tect e
noogle />
Ymenu >
Mainhctivithy java
Soo)-showc);
3
else if Cd=» R- idgoog le)i
3
4
Source Code
string [Link]
Cresources >
<string
namem"Male /sring
cstring name e "f
female
</string
string name =o">Other
</ss-ings
resourcess
Actvi-mainm
<Relativelayput
LTetview
android: id ="tid/tetview1"
android4et
LRadioGiroup
=sring /tet">
LRadioBuHon android :id
="tid/ radioGroup4")
android:
id="tid/radioo
androicl ttdt="e string/ m" >
LRadioButton
MainActiv
ityjava
Public
Clags Main Activity
B4on etends Activity
btn)
Radio
Grop rdg i
Radioßutton rdb
protected void
Oncreate CBun ale
SavellngtaeState)i
btn=cButton)
rdg
(Radioroup)
find Views By ld [Link] .button1)
findview&ld [Link].
radio
[Link] on Group1)
clickListher Cnew
onlicdkListherCo1
publie vod Oncick
view
argo)i
int
selectedid =rdq -qetchacked
Radio 13utto nld Co >
rdb =(Ra dio
Buton)
findview
yld Cselected la)
Toastnavetet
CmainActivity-this,
rdb-gerteet c).Toast.
LEN
TH_SHORT). show c)
3;
3
Program7 22-2- 2025
Write
prgram to
Spin 4i+ems
Source code
MainActivit java
onltenSelected lisner
f
class Maintetivity extends Acivity implements
publie
Spinner sPi
TextView ti
Heybord;"Mouse", *printe:speaker
j;
String CJ itemg
adt hew
ArragAdapter csiring > ArraAdapter estring Cthiss android. Rlayout
<Relative layout
<spinner
android:id <"@id/spinner4
2Tet view
androld :id ="@+ id/teView1"
Nrte
program to Emul ate a Stoplwateh
SourceCode
(resour ces
(string
Yarings
activitmain m
<Rlativelayou>
LText View
andraiditert
o0:00:00
(Button
android:text =
LButton
android:id =@ tid /button 2
android:tezt =@ string bz
<Button
andvoid: id @tid/ buton g "
android : tert =@siring/ss >
Mainhctivitt jave
publie class
MainAciity extendo activiy t
private Buton Start B utton
imelwamillisecondls =oL;
long
(Rid+evie);
.
timervalue = Cevien) finelview B ll
PauseButton
= CButton)
findView By ld
[Link].buton2) ;
SetOn Click Listher
(ew [Link] Listher (
public void onclick (ew view) $
See 3 = Secs % 60
s
Program
Source code
activiy-main.
<Rlativelayouts
<kheck Box
androd id="'+i4/checkBo"
(check Box
androd: id = tid /check Box 2
android : text"estring
/$J" >
checkBox
Box3
: id="+id check
android
<Button
Ondroid id =e tid/butten1"
(resources>
striy
name p"> PHe L|string >
s4per. onereate
Csaved Instance
Stase):
5eContentvies CR layous.
activitymain)
chk2 >Ccheck
Box)
finaviewByld
[Link].
chk2= checkBona)
Ccheek Bor ) find View Byld
([Link]. checkBo
hks =lcheekBo) 2);
fndView By ld C [Link]. check Boes):
hka
cheek Bor)
findviewBy ld [Link].
checkBoe):
bn =CButton)
findview3yld [Link]
b+n. se4
button 4);
On clickListher
this):
3
13
Write
program
to
the Colour of the
change Backgrourd
acivity
Source Code
strings m)
<resources >
Jresources>
Qchvity- [Link]
<8utton
andro'd: id =" id/ buton
2Button
android: id = etid/B utton?"
Man Activityjava
pretected void
onCreate CBundle Savedlnstance stae) i
fina
id (R id.r1):|
Plativelayot ri CPelativeLayot) findviewoy
20
3
21
|-3-2025
Pprogram
AlM- Write
prog ram to
change the backgourd image
Source Code
activitymain- xm
<Rlativelayout >
Buton
androidd: id =`+id (button"
anroid :tex = Image 1
(Button
andr oid:id ="+id /button2"
(mageView
MainAei iy java
Imageview 4;
Button btn1, bn2
protected void onCreae CBundle Savedlnstancestate) s
Switeh
onClie
Cv geld C)
view
)i
) 22
break ?
V1SetmageResource (R:drawable. by :
break ;
Program 12
|
-3-2o25
Am :Write
pregram Display
image fhon local drive of the
Computer
ource coele
[Link] xmt
<Rlativelayot>
<image view
android :id = tid /image viewa "
andlroid: sre = " drawable / bg t")>
(B4Hon
an droid :id= O +id/btn Changel m age "
android: texte changelmage
</Relativelayout>
Main. AHviyjava
Button button:
Imageview image s
AM rite a
display muliplic ation tabie of a given number
program to
Source code
[Link]
E ditrex+
<Button
android :id= " +id /bttong"
android: tezt "Buton "/>
<Tectvi ew
teztViewt
android:id"+idl
android:tect"
PRlativelayou>
Buton
Tet
int
view
ans
btn;
=
t;
1
proteced void
on Create (Bundle Sav ed In stanceState) §
tetCEdiTez) find ViewByld CR:id edit Tex4) ;
bn =Coutton) fndview Byld (R-id button4 J:
+ztv = CTet view) view Byld CR-id .tezview1):
fined
program 14
sourte Code
[Link]!
<Relative Layout
(But ton
android:id ="tid buton1
LTetview
/Pelative Layout>
MainActviy java
Button buttn;
Tezsview ttview
public void
onclick Cview arg o)
wAManager = (wifManger)
string ipAddress=
wifiManager
for matter
ge sysemserie
lS
.fornatIPAddress
(wi Manager getConn econ
nfoc)ger lPAddre ss C) )
27
Program is
AIM
Source Code
activitymain. em!
<RelativelLdypu>
LListview >
<Jis+ View
M
ainAciviyjava
Shatic final s}ring CJ FRUI TS= new S+ring I {apple", Avs Cado3anam
ser List Adaer Cnew ArrayaAapler < Str ing Cohis, RiLayot aivityain,
FRUTS ));
is+Vie
Lis+View gelisivie cs;