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.
As usual, you should be done with previous tests before proceeding.
Specifically, you should be passing
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.
We’re almost there! At this point:
MainActivitycan launch the
CourseActivityand pass it details on the course to display
All 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
Strings 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.
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
MainActivityso that it correctly generates an
Intentwhen a course is clicked, which will pass
CourseActivityclass so that it correctly displays the course description using the information provided by the
getCoursemethod you completed on your API client, which will pass