Android Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

1)I

nst
allSDKandJDKi
nAndr
oidSt
udi
o
Fol
lowt hesest
epstodownloadandinst
allt
hel
atestv
ersi
onofAndr
oidSDKpl
atf
orm
packagesandtool
sony ourhostcomputer
:
1.Aft
eri
nst
all
i
ngAndr
oidStudi
o,fol
lowanyoneoft
hesest
epst
oopenSDKManager
fr
om t
heAndroi
dSt
udioappl
icati
on:
 Ont
heAndr
oidSt
udi
olandi
ngpage,
sel
ectConf
igur
e>SDKManager
.
Fr
om y
ourAndr
oidSt
udi
oappl
i
cat
iont
ool
bar
,sel
ectTool
s>Andr
oid>SDKManager
.

 Fr
om y
ourAndr
oidSt
udi
oappl
i
cat
iont
ool
bar
,cl
i
ckSDKManager
.

2.I
nt heDefaul
tSet
tingsdialogbox,
cli
ckt
heset
abst
oinst
all
Andr
oidSDKpl
atf
orm
packagesanddevelopertool
s:
 SDKPl
atf
orms—Sel
ectt
hel
atestAndr
oidSDKpackaget
ocompi
l
eyour
appl
i
cat
ionwi
tht
hel
atestv
ersi
onofSDKpl
atf
orm.
 SDKTool
s—Sel
ectt
hel
atestAndr
oidSDKBui
l
d-Tool
s,NDK(
SidebySi
de)
,and
Andr
oidSDKPl
atf
orm-
Tool
s.
1.Cli
ckApply.Androi
dSt udi
ost ar
tsinst
all
i
ngt
heselect
edpackagesandtool
sonyour
computer
.Oncei nst
all
ed, t
heStatusofthei
nst
all
edpackagesandtool
schanges
fr
om Notinstal
ledtoInstall
ed.
2.Cl
i
ckOK.

I
nst
all
JDK
1.
Openyourpr
ojecti
nAndroi
dStudi
oandselectFi
le>Set
ti
ngs...>Bui
ld,
Execution,
Depl
oyment>BuildTool
s>Gradle(Andr
oidStudi
o>Pref
erences..
.>Buil
d,Executi
on,
Depl
oyment>BuildTool
s>GradleonaMac) .
2.
UnderGr
adl
eJDK,
chooset
heEmbeddedJDKopt
ion.
3.
Cli
ckOK.
2)Creat
e“ Hel
loWor
ld”appl
icat
ion.Thatwi
lldi
spl
ay“
Hel
loWor
ld”i
nthemi
ddl
eof
thescreenusi
ngText
ViewWi dgeti
ntheredcol
or

act
ivi
ty_
mai
n.xml

<?xmlv ersi
on=" 1.
0"encodi ng="ut f
-8"? >
<Relat
iveLayoutxml ns: androi
d=" htt
p: //schemas.androi
d.com/
apk/
res/
andr
oid"
xmlns:app=" htt
p:/
/schemas. androi d.com/apk/res-
auto"
xmlns:tools="htt
p://schemas. andr oid.com/tools"
android:l
ayout _
width=" match_par ent"
android:l
ayout _
height ="
mat ch_par ent "
tool
s:context ="
.MainAct i
vit
y">

<TextView
android:
l
ay out_
width="wrap_content"
android:
l
ay out_
height="
wr ap_content
"
android:
text="
Hell
oWor l
d!"
android:
textCol
or="#FF0000"/>

</
Relat
iveLay
out
>
Output
3)Createregi
str
ati
onpaget
odemonst
rat
ionofbasi
cwi
dget
sav
ail
abl
ein
android
<Relat
iveLayoutxml ns:
android=http://schemas. android.com/apk/
res/
andr
oid
xmlns:
tools=http:
//schemas.andr oid.com/ t
ool s
androi
d:layout
_width="match_ parent"
androi
d:layout
_height="match_ parent"
androi
d:paddingLeft="@di
men/ activi
ty_hori
zont al
_mar gin"
androi
d:paddingRight="@di
men/ act i
vit
y_horizontal
_mar gin"
androi
d:paddingTop=" @di
men/ activi
ty_vert
ical_margin"
androi
d:paddingBottom="@di men/ acti
vit
y_verti
cal_mar gin"
>

<Relat
iveLay out
android:
layout_width="mat ch_ parent"
android:
layout_height="
wr ap_ cont ent
"
android:
id="@+id/NameLay out "
>
<TextView
android:
layout_width="wrap_ cont ent"
android:
layout_height="
wr ap_ cont ent
"
android:
text="Name"
android:
id="@+id/textView" />

<Edi
tText
andr
oid:l
ayout_
wi dth="wrap_content"
andr
oid:l
ayout_
hei ght="
wr ap_content
"
andr
oid:i
nputType="textPersonName"
andr
oid:i
d="@+id/name"
andr
oid:
hint="
Entery ourname. ."/
>

<TextView
android:
layout
_width="wrap_content"
android:
layout
_height="
wr ap_content
"
android:
text="
Emai l
"
android:
id="@+id/
textView2"/ >

<Edi
tText
andr
oid:l
ayout_width="wrap_content"
andr
oid:l
ayout_height="
wr ap_content"
andr
oid:i
nputType="textEmailAddress"
andr
oid:i
d="@+i d/email
"
andr
oid:hi
nt="enteryouremai laddress"/
>

<Text
View
andr
oid:
l
ay out
_width="wrap_content"
andr
oid:
l
ay out
_height="
wr ap_content
"
andr
oid:
text="
Age"
andr
oid:
i
d=" @+id/
textView3"/ >

<Edi
tText
andr
oid:l
ayout_width=" wrap_content"
andr
oid:l
ayout_height ="
wr ap_content
"
andr
oid:i
nputType=" number "
andr
oid:ems="10"
andr
oid:i
d="@+id/ age"
andr
oid:hi
nt="Entery ourage.."/>

<TextView
android:
layout_
width="wrap_content"
android:
layout_
height="
wr ap_content
"
androi
d:text="
Gender"
android:
id="@+id/
textView4"/>
<RadioGroup
android:
id="@+id/
radioSex"
android:
layout_
width="wrap_content"
android:
layout_
height="
wr ap_content
">

<RadioButton
android:
layout
_width="wrap_content"
android:
layout
_height="
wr ap_content
"
android:
text="
Male"
android:
checked="tr
ue"
android:
id="@+id/
mal e"/>
<RadioButton
android:
layout
_width="wrap_content"
android:
layout
_height="
wr ap_content
"
android:
text="
Female"
android:
id="@+id/
femal e"
/ >
</RadioGroup>

<TextView
android:
layout
_width="wrap_content"
android:
layout
_height="
wr ap_content
"
android:
text="
Branch"
android:
id="@+id/t
extView5"/>
<Spinner
android:
layout
_width="f
ill
_parent"
andr
oid:
l
ayout
_height
="wrap_cont
ent
"
andr
oid:
i
d="@+id/
branch"/>

<But
ton
andr
oid:
l
ay out
_width="wrap_content"
andr
oid:
l
ay out
_height="
wr ap_content
"
andr
oid:
text="
Submi t
"
andr
oid:
i
d=" @+id/
send" /
>

<CheckBox
androi
d:l
ay out
_width="wrap_content"
androi
d:l
ay out
_height="
wr ap_content
"
androi
d:text="
Hindi"
androi
d:i
d=" @+id/hi
ndi"
androi
d:checked="fal
se"/>

<CheckBox
androi
d:l
ay out
_widt h="wr ap_content"
androi
d:l
ay out
_height ="wr ap_content
"
androi
d:text="
English"
androi
d:i
d=" @+id/engl i
sh"
androi
d:l
ay out
_ali
gnBot tom=" @+id/hi
ndi
"
androi
d:l
ay out
_toEndOf ="@+i d/hi
ndi"
androi
d:checked="false"/ >

<TextView
android:
layout_
width="wrap_content"
android:
layout_
height="
wr ap_content
"
android:
text="
Language"
android:
id="@+id/t
extView7"/ >
</Relati
veLayout>
4) Createsampleappli
cati
onwit
hlogi
nmodule.(
checkuser
nameandpasswor d)on
successfull
ogi
n,Changetextv
iew“l
ogi
nsuccessful
”andonlogi
nfai
l,
aler
tuserusing
Toast”LoginFai
l”
.

Activitymai n.xml
<?xml version=" 1.0"encodi ng="utf-
8"?>
<Rel ati
veLay outxml ns:
android="htt
p://
schemas.andr
oid.
com/
apk/
res/
andr
oid"
xml ns:app=" ht t
p://schemas. androi
d.com/apk/r
es-aut
o”
xml ns:tools=" http:/
/ schemas. androi
d.com/tool
s"
andr oid:l
ay out_wi dth=" match_parent"
andr oi
d:layout _height ="match_parent"
tools:cont ext=".Mai nAct i
vi
ty">

<TextView
android:
layout
_width="wrap_content"
android:
layout
_height="
wr ap_content
"
android:
text="
LOGINFORM"
android:
textSi
ze="
18dp" /
>

<Edi
tText
androi
d:i
d="@+i d/
edi t
Text"
androi
d:l
ayout_width="wrap_ content"
androi
d:l
ayout_height="wrap_ content
"
androi
d:ems="10"
androi
d:hi
nt="User-name"
andr
oid:
inputType="textPersonName"/ >

<Edi
tText
androi
d:i
d="@+id/edi t
Text2"
androi
d:l
ayout_width="wrap_content"
androi
d:l
ayout_height="wrap_content
"
androi
d:ems="10"
andr
oid:
input
Type=" textPassword"/>

<TextView
android:
id="@+id/
textView"
android:
layout
_width="121dp"
android:
layout
_height="21dp"
android:
text="
USERNAME"
android:
textSi
ze="
18dp"/ >

<TextView
android:
id="
@+i
d/t
ext
View2"
andr
oid:
l
ay out
_width="121dp"
andr
oid:
l
ay out
_height="21dp"
andr
oid:
text="
PASSWORD"
andr
oid:
textSi
ze="
18dp"/ >

<But
ton

andr
oid:
i
d="
@+i
d/but
ton"

andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"

andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"

andr
oid:
onCl
i
ck="
submi
t"

andr
oid:
text
="But
ton"/
>

</
Rel
ati
veLay
out
>

Mai
nact
ivi
ty.
jav
a

i
mpor tandroid.os. Bundl e;
impor tandroi d.view. View;
impor tandroi d.wi dget.But t
on;
impor tandroi d.wi dget.EditText;
impor tandroi d.wi dget.Toast ;
publicclassMai nAct i
vityextendsAppCompat Activ
ity
{
Edit
Textuname, passwor d;
Buttonb1;
@Ov erri
de
protectedvoi donCr eat e(BundlesavedInst anceState)
{super .
onCr eate(sav edInstanceStat
e); setContentView(
R.l
ayout
.act
ivi
ty_
mai
n);
uname=f i
ndVi ewBy I
d(R. i
d.edit
Text)
;
passwor d=findVi ewBy Id(R.i
d.edit
Text2);
b1=findViewBy I
d( R.id.button);
}
publicvoidsubmi t(Viewv i
ew)
{
if(uname. get Text ().
toSt r
ing().
equal
s("RCP" ))
{
i
f(passwor d. getText ().toStri
ng().
equals("ACS"))
{
Toast .makeText (get Appl i
cati
onContext (
),"l
ogin
Successful
",
Toast.
LENGTH_SHORT).
show()
;
}
Else
{
Toast.makeText(
getAppl
i
cati
onCont
ext(
),
"l
ogi
n
Unseccessful
",
Toast.
LENGTH_SHORT).
show()
;
}
}
}
}

Out
put
:-
5)Cr
eat
eanAppl
icat
ionf
orDemonst
rat
ionofScr
olli
nAndr
oid

Fi
le:act
ivi
ty_
mai
n.xml
<?
xmlv
ersi
on="
1.0"encodi
ng="
utf
-8"
?>
<Rel
ati
veLay
outxml
ns:
andr
oid="
htt
p:/
/schemas.
andr
oid.
com/
apk/
res/
andr
oid"
xml
ns:
tool
s="
htt
p:/
/schemas.
andr
oid.
com/
tool
s"
andr
oid:
l
ayout
_wi
dth="
mat
ch_
par
ent
"
andr
oid:
l
ayout
_hei
ght
="mat
ch_
par
ent
">

<Text
View
andr
oid:
l
ayout
_wi
dth="
wrap_
cont
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
Appear
ance="
?andr
oid:
att
r/t
ext
Appear
anceMedi
um"
andr
oid:
text
="Ver
ti
cal
Scr
oll
Viewexampl
e"
andr
oid:
i
d="
@+i
d/t
ext
View"
andr
oid:
l
ayout
_gr
avi
ty="
cent
er_
hor
izont
al"
andr
oid:
l
ayout
_cent
erHor
izont
al="
tr
ue"
andr
oid:
l
ayout
_al
i
gnPar
ent
Top="
tr
ue"/
>

<Scr
oll
Viewandr
oid:
l
ayout
_mar
ginTop="
30dp"
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
i
d="
@+i
d/scr
oll
View"
>

<Li
near
Lay
out
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="f
il
l_
par
ent
"
andr
oid:
ori
ent
ati
on="
ver
ti
cal
">
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton1"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton2"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton3"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton4"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton5"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton6"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton7"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton8"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton9"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton10"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton11"/
>
<But
ton
andr
oid:
l
ayout
_wi
dth="
fi
ll
_par
ent
"
andr
oid:
l
ayout
_hei
ght
="wr
ap_
cont
ent
"
andr
oid:
text
="But
ton12"/
>
</
Linear
Lay
out
>
</
Scr
oll
View>
</
Rel
ati
veLay
out
>

Out
put
:-

You might also like