Professional Documents
Culture Documents
03-3 Exercise 3 - 4
03-3 Exercise 3 - 4
Page 1 of 7
NOTE: For all online practical, create all activity using the following package. The online
auto-checker is looking for a specific format.
Name: madpractical
Package: sg.edu.np.mad.madpractical
1. Modify the onClickListener of left button to show a Toast message. The toast message will
show Followed if the user click on the Follow button, and vice versa.
Page 2 of 7
3. In the activity_list layout file, create an ImageView, position it in the middle of the screen.
4. Create an onClickListener for the image created in previous step. Upon clicking the image,
an AlertDialog will appear as shown in the figure below.
Page 3 of 7
5. Upon clicking the View button, a random integer will be generated. The MainActivity
(created in previous practical) will be launched, and the random integer is sent over.
6. Modify the MainActivity to display the random integer together with the name.
Page 4 of 7
CHALLENGE
8. Create an event listener for the Message button. Upon clicking on the button, the Activity
created in previous step, MessageGroup, will be launched.
Buttons
FrameLayout
Page 5 of 7
10. Fragments are commonly used in Android applications. They are an extension to Activities.
Research and discover how to implement loading of fragment within an activity.
Implement MessageGroup as illustrated in the image below.
https://guides.codepath.com/android/creating-and-using-fragments#embedding-a-
fragment-in-an-activity
Clicking on Group 2
Clicking on Group 1
Page 6 of 7
1. Create a List of 20 User objects in the ListActivity. Randomize the name, descriptions and
value of Followed.
3. Add an onClickListener for the image such that it will show an Alert Dialog with the
corresponding name. Clicking on the view button will direct the user to the MainActivity
to show the profile page. Toggling the Follow button should save the state back in the
respective User object.
Page 7 of 7
4. Modify the RecyclerView such that if the last digit of the name contains 7, a different
layout is used as shown below. This new layout will have an additional ImageView that
occupies the width of the screen and has a width-to-height ratio of 1:1.