Two Responsive Screens
-
Upload
julius-depulla -
Category
Documents
-
view
218 -
download
0
Transcript of Two Responsive Screens
-
8/2/2019 Two Responsive Screens
1/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
P r o g r a m m i n g M o b i l e P h o n e s
T w o r e s p o n s i v e s c r e e n s , c o m m u n i c a t i n g u s i n g e x p l i c i t i n t e n t s
I a n B a y l e y
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
L e c t u r e O v e r v i e w I
1
A d d i n g a M e n u t o H e l l o W o r l d
H o w t o p r o g r a m m e n u s
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a
2
A d d i n g a n I n t e n t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
3
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
2/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o p r o g r a m m e n u s
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a
1 . A d d i n g a M e n u t o H e l l o
W o r l d
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o p r o g r a m m e n u s
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a
H o w t o p r o g r a m m e n u s
1
w h e n t h e m e n u b u t t o n i s p r e s s e d , a d d o p t i o n s t o a M e n u o b j e c t
o v e r r i d e A c t i v i t y m e t h o d o n C r e a t e O p t i o n s M e n u
c a l l M e n u m e t h o d a d d t o g i v e i t a l a b e l a n d i d 0 , 1 , 2 . . .
t w o d u m m y a r g u m e n t s g r o u p I d = o r d e r = 0
2
w h e n a n o p t i o n i s s e l e c t e d , n d o u t w h i c h o n e i t i s a n d r e s p o n d
o v e r r i d e A c t i v i t y m e t h o d o n O p t i o n s I t e m S e l e c t e d
c a l l M e n u I t e m m e t h o d g e t I t e m I d t o g i v e i d 0 , 1 , 2 . . .
c o n t e x t m e n u s a r e s i m i l a r
S i m p l e s t a p p t h a t h a s a m e n u
s h o w t h e i d f o r e a c h m e n u i t e m a s a t o a s t
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
3/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o p r o g r a m m e n u s
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a I
p u b l i c c l a s s H e l l o W o r l d M e n u e x t e n d s A c t i v i t y {
@ O v e r r i d e
p u b l i c v o i d o n C r e a t e ( B u n d l e s a v e d I n s t a n c e S t a t e ) {
s u p e r . o n C r e a t e ( s a v e d I n s t a n c e S t a t e ) ;
s e t C o n t e n t V i e w ( R . l a y o u t . m a i n ) ;
}
@ O v e r r i d e
p u b l i c b o o l e a n o n C r e a t e O p t i o n s M e n u ( M e n u m e n u ) {
s u p e r . o n C r e a t e O p t i o n s M e n u ( m e n u ) ;
f o r ( i n t i = 0 ; i < 1 3 ; i + + )
m e n u . a d d ( M e n u . N O N E , i , M e n u . N O N E , " o p t i o n " + i ) ;
r e t u r n t r u e ;
}
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o p r o g r a m m e n u s
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d M e n u . j a v a I I
@ O v e r r i d e
p u b l i c b o o l e a n o n O p t i o n s I t e m S e l e c t e d ( M e n u I t e m i t e m ) {
s u p e r . o n O p t i o n s I t e m S e l e c t e d ( i t e m ) ;
T o a s t . m a k e T e x t ( t h i s ,
" s e l e c t e d " + i t e m . g e t I t e m I d ( ) ,
T o a s t . L E N G T H _ S H O R T ) . s h o w ( ) ;
r e t u r n t r u e ;
}
}
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
4/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
2 . A d d i n g a n I n t e n t t o H e l l o
W o r l d
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
D e n i t i o n o f i n t e n t
a m e s s a g e f r o m o n e a c t i v i t y t o t e l l a n o t h e r a c t i v i t y t o s t a r t .
H o w t o s t a r t a n a c t i v i t y w i t h a n e x p l i c i t i n t e n t
I n t e n t i n t e n t = n e w
I n t e n t ( f r o m A c t i v i t y O b j e c t , t o A c t i v i t y C l a s s . c l a s s ) ;
s t a r t A c t i v i t y ( i n t e n t ) ;
u s e A c t i v i t y m e t h o d f i n i s h t o e n d
S i m p l e s t a p p t h a t u s e s i n t e n t s
m o v e t o s u b a c t i v i t y w h e n b u t t o n i s p r e s s e d , t h e n b a c k a g a i n
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
5/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a I
p u b l i c c l a s s H e l l o W o r l d I n t e n t e x t e n d s A c t i v i t y {
B u t t o n b u t t o n ;
@ O v e r r i d e
p u b l i c v o i d o n C r e a t e ( B u n d l e s a v e d I n s t a n c e S t a t e ) {
s u p e r . o n C r e a t e ( s a v e d I n s t a n c e S t a t e ) ;
s e t C o n t e n t V i e w ( R . l a y o u t . m a i n ) ;
b u t t o n = ( B u t t o n ) f i n d V i e w B y I d ( R . i d . b u t t o n ) ;
b u t t o n . s e t O n C l i c k L i s t e n e r ( n e w O n C l i c k L i s t e n e r ( ) {
@ O v e r r i d e
p u b l i c v o i d o n C l i c k ( V i e w v ) {
I n t e n t i n t e n t = n e w I n t e n t (
g e t A p p l i c a t i o n C o n t e x t ( ) ,
H e l l o W o r l d I n t e n t S u b . c l a s s ) ;
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a I I
s t a r t A c t i v i t y ( i n t e n t ) ;
}
} ) ;
}
}
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
6/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a I
p u b l i c c l a s s H e l l o W o r l d I n t e n t S u b e x t e n d s A c t i v i t y {
B u t t o n b u t t o n ;
@ O v e r r i d e
p u b l i c v o i d o n C r e a t e ( B u n d l e s a v e d I n s t a n c e S t a t e ) {
s u p e r . o n C r e a t e ( s a v e d I n s t a n c e S t a t e ) ;
s e t C o n t e n t V i e w ( R . l a y o u t . m a i n ) ;
b u t t o n = ( B u t t o n ) f i n d V i e w B y I d ( R . i d . b u t t o n ) ;
b u t t o n . s e t O n C l i c k L i s t e n e r ( n e w O n C l i c k L i s t e n e r ( ) {
@ O v e r r i d e
p u b l i c v o i d o n C l i c k ( V i e w v ) {
f i n i s h ( ) ;
}
} ) ;
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a I I
}
}
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
7/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e A n d r o i d M a n i f e s t . x m l I
< ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " u t f - 8 " ? >
< m a n i f e s t
x m l n s : a n d r o i d = " h t t p : / / s c h e m a s . a n d r o i d . c o m / a p k / r e s / a n d r o i d "
p a c k a g e = " u k . a c . b r o o k e s . b a y l e y "
a n d r o i d : v e r s i o n C o d e = " 1 " a n d r o i d : v e r s i o n N a m e = " 1 . 0 " >
< u s e s - s d k a n d r o i d : m i n S d k V e r s i o n = " 7 " / >
< a p p l i c a t i o n a n d r o i d : i c o n = " @ d r a w a b l e / i c o n "
a n d r o i d : l a b e l = " @ s t r i n g / a p p _ n a m e " >
< a c t i v i t y a n d r o i d : n a m e = " . H e l l o W o r l d I n t e n t "
a n d r o i d : l a b e l = " @ s t r i n g / a p p _ n a m e " >
< i n t e n t - f i l t e r >
< a c t i o n
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
T h e l e A n d r o i d M a n i f e s t . x m l I I
a n d r o i d : n a m e = " a n d r o i d . i n t e n t . a c t i o n . M A I N "
/ >
< c a t e g o r y a n d r o i d : n a m e =
" a n d r o i d . i n t e n t . c a t e g o r y . L A U N C H E R " / >
< / i n t e n t - f i l t e r >
< / a c t i v i t y >
< a c t i v i t y a n d r o i d : n a m e = " . H e l l o W o r l d I n t e n t S u b "
a n d r o i d : l a b e l = " @ s t r i n g / a p p _ n a m e 2 " >
< / a c t i v i t y >
< / a p p l i c a t i o n >
< / m a n i f e s t >
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
8/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
H o w t o u s e i n t e n t s t o c r e a t e a s u b a c t i v i t y
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d I n t e n t S u b . j a v a
T h e l e A n d r o i d M a n i f e s t . x m l
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
H o w t o u s e i n t e n t s t o c o m m u n i c a t e w i t h t h a t s u b a c t i v i t y
U s i n g t h e r e s u l t f o r s o m e t h i n g
s t a r t A c t i v i t y F o r R e s u l t ( i n t e n t , r e q u e s t C o d e ) ;
. . .
p u b l i c v o i d o n A c t i v i t y R e s u l t
( i n t r e q u e s t C o d e , i n t r e s u l t C o d e , I n t e n t d a t a ) ;
/ / c a l l e d a u t o m a t i c a l l y o n r e t u r n
B u n d l i n g d a t a t o p a s s a n d u n b u n d l i n g i t a g a i n
i n t e n t . p u t E x t r a ( v a r i a b l e N a m e , v a l u e ) ;
. . . ( t y p e ) d a t a . g e t E x t r a s ( ) . g e t ( v a r i a b l e N a m e )
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
3 . A d d i n g a r e s p o n s i v e L i s t V i e w
a n d E d i t T e x t t o H e l l o W o r l d
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
9/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
W h a t w e n e e d t o d o
1
a d d a n u n r e s p o n s i v e l i s t v i e w
2
a d d a l i s t t o a n a d a p t e r a n d a d d t h e a d a p t e r t o t h e l i s t v i e w
a n a d a p t e r m a k e s a v i e w f o r e a c h i t e m i n t h e l i s t
o n e p a r a m e t e r s u p p l i e s a l a y o u t f o r t h i s
3
m a k e i t r e s p o n d t o a n i t e m c l i c k e v e n t
n o t e g e n e r i c s a w k w a r d n e s s !
4
a d d a n u n r e s p o n s i v e e d i t t e x t
5
m a k e i t r e s p o n d t o a k e y e v e n t
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e r e s \ l a y o u t \ m a i n . x m l I
-
8/2/2019 Two Responsive Screens
10/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e r e s \ l a y o u t \ m a i n . x m l I I
a n d r o i d : t e x t = " E d i t T e x t "
a n d r o i d : i d = " @ + i d / e d i t T e x t " >
< / E d i t T e x t >
< / L i n e a r L a y o u t >
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a I
p u b l i c c l a s s H e l l o W o r l d L i s t V i e w e x t e n d s A c t i v i t y {
p r i v a t e L i s t V i e w l i s t V i e w ;
p r i v a t e E d i t T e x t e d i t T e x t ;
p r i v a t e f i n a l S t r i n g [ ] C O L O U R S =
n e w S t r i n g [ ] { " G r e e n " , " R e d " } ;
@ O v e r r i d e
p u b l i c v o i d o n C r e a t e ( B u n d l e s a v e d I n s t a n c e S t a t e ) {
s u p e r . o n C r e a t e ( s a v e d I n s t a n c e S t a t e ) ;
s e t C o n t e n t V i e w ( R . l a y o u t . m a i n ) ;
l i s t V i e w =
( L i s t V i e w ) f i n d V i e w B y I d ( R . i d . l i s t V i e w ) ;
e d i t T e x t =
( E d i t T e x t ) f i n d V i e w B y I d ( R . i d . e d i t T e x t ) ;
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
11/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a I I
l i s t V i e w . s e t A d a p t e r (
n e w A r r a y A d a p t e r < S t r i n g > ( t h i s ,
a n d r o i d . R . l a y o u t . s i m p l e _ l i s t _ i t e m _ 1 ,
C O L O U R S ) ) ;
l i s t V i e w . s e t O n I t e m C l i c k L i s t e n e r (
n e w O n I t e m C l i c k L i s t e n e r ( ) {
@ O v e r r i d e
p u b l i c v o i d o n I t e m C l i c k (
A d a p t e r V i e w < ? > p a r e n t ,
V i e w v i e w ,
i n t p o s i t i o n , l o n g i d ) {
i f ( p o s i t i o n = = 0 )
l i s t V i e w . s e t B a c k g r o u n d C o l o r ( C o l o r . G R E E N ) ;
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a I I I
e l s e
l i s t V i e w . s e t B a c k g r o u n d C o l o r ( C o l o r . R E D ) ;
T o a s t . m a k e T e x t ( g e t A p p l i c a t i o n C o n t e x t ( ) ,
C O L O U R S [ p o s i t i o n ] ,
T o a s t . L E N G T H _ S H O R T ) . s h o w ( ) ;
}
}
) ;
e d i t T e x t . s e t O n K e y L i s t e n e r ( n e w O n K e y L i s t e n e r ( ) {
@ O v e r r i d e
p u b l i c b o o l e a n o n K e y ( V i e w v , i n t k e y C o d e ,
K e y E v e n t e v e n t ) {
i f ( ( e v e n t . g e t A c t i o n ( ) = =
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s
-
8/2/2019 Two Responsive Screens
12/12
A d d i n g a M e n u t o H e l l o W o r l d
A d d i n g a n I n t e n t t o H e l l o W o r l d
A d d i n g a r e s p o n s i v e L i s t V i e w a n d E d i t T e x t t o H e l l o W o r l d
W h a t w e n e e d t o d o
T h e l e r e s \ l a y o u t \ m a i n . x m l
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a
T h e l e s r c \ . . . \ H e l l o W o r l d L i s t V i e w . j a v a I V
K e y E v e n t . A C T I O N _ D O W N ) & & ( k e y C o d e = =
K e y E v e n t . K E Y C O D E _ D P A D _ C E N T E R ) ) {
e d i t T e x t . s e t T e x t ( " " ) ;
}
r e t u r n f a l s e ; / / h a s n ' t c o n s u m e d t h e e v e n t
}
} ) ;
}
}
I a n B a y l e y P r o g r a m m i n g M o b i l e P h o n e s