To wrap up MP2, we’ll add support for viewing details about a single course to our app. We’ll add a new activity that uses the support for retrieving course information we’ve already added to our API server and client.
MainActivity
Course ClickedMainActivity
Course ClickedAs usual, you should be done with previous tests before proceeding.
Specifically, you should be passing test0_CourseClassDesign
, test1_ServerCourseRoute
, and test2_ClientGetCourse
.
We’ll be using all of that functionality to wrap up MP2!
Our first step is to add the ability to handle clicks on summaries in our summary list.
This is where we’ll launch our new CourseActivity
, and so we’ll also have a chance to discuss how to launch an activity in Android.
Note that, as described in the walkthrough above, to pass the test case here you need to add a String
extra to the Intent
with the key “summary” containing the summary that was clicked serialized to JSON.
You should use the information and guidance about serialization we’ve provided in past lessons.
CourseActivity
UICourseActivity
UIWe’re almost there! At this point:
/course/
routegetCourse
methodMainActivity
can launch the CourseActivity
and pass it details on the course to displayAll that’s left is to finish our CourseActivity
so that the details about the course are shown!
Let’s see how to do that.
When you are done, your CourseActivity
should display the title for the course—equivalent to the toString
method for the Summary
—and the course description.
You don’t need two separate UI components to do this, but the two String
s should be separated by whitespace.
For this final bit of MP2 we’re providing a bit less explicit guidance, to give you a chance to spread your wings.
You can do it!
Refer to the code in the MainActivity
for help, since there are great things to mimic there.
Ask on the forum or tutoring site when you get stuck.
Have fun!
As a reminder, on lessons where we focus on the machine project we will not assign a homework problem! However, the lesson will usually focus on helping you complete a particular part of the MP test suite, and so we encourage you to spend time on that in lieu of a homework problem.
Right now your goal should be to
MainActivity
so that it correctly generates an Intent
when a
course is clicked, which will pass test3_SummaryClickLaunch
CourseActivity
class so that it correctly displays the course
description using the information provided by the Intent
and the
getCourse
method you completed on your API client, which will pass
test4_CourseView
If you get stuck, find us for help on the tutoring site or forum. If you have extra time after today’s lesson, you may want to move on and begin work on the next lesson, which also covers MP1.