Continuing from last week, you will be adding interactivity to your app.
Follow the instructions below to complete your app.
- Modify the onClickListener of left button to show a Toast message. The toast message will show
Followed
if the user click on theFollow
button, and vice versa.
-
Create a new Empty Activity with the following configuration,
- Activity Name: ListActivity
- Generate a Layout File: Checked
- Layout Name: activity_list
- Launcher Activity: Checked
- Source Language: Java
-
In the
activity_list
layout file, create anImageView
, position it in the middle of the screen.
- Create an
onClickListener
for the image created in previous step. Upon clicking the image, anAlertDialog
will appear as shown in the figure below.
-
Upon clicking the
View
button, a random integer will be generated. TheMainActivity
(created in previous practical) will be launched, and the random integer is sent over. -
Modify the
MainActivity
to display the random integer together with the name.
-
Create a new Empty Activity with the following configuration,
- Activity Name: MessageGroup
- Generate a Layout File: Checked
- Layout Name: activity_message_group
- Launcher Activity: Unchecked
- Source Language: Java
-
Create an event listener for the
Message
button. Upon clicking on the button,MessageGroup
created in previous step will be launched.
- Modify the layout of
MessageGroup
to as shown in the image below.
- 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.
ImplementMessageGroup
as illustrated in the image below.
[https://guides.codepath.com/android/creating-and-using-fragments#embedding-a-fragment-in-an-activity]
To submit your practical, remember to commit the changes and push to remote repository.