If resultCode

Log. d ("CH12 ", "Good Close, let's update our list"); click events

JobEntry je = JobEntry. fromBundle (data.getExtras ()) ; <— on List

break;

Update the list with via replace method

Extract returned JobEntry

The objective of this code is to display a list of available jobs to the user in a ListView ©. In order to display the list of jobs we must first parse the list stored on the device O. Note that the Context argument is required to allow the JobList class access to the private file area for this application. If the parse fails, we initialize the JobList instance to a new, empty list. This is a somewhat simplistic way to handle the error without the GUI falling apart Q.

When a specific job is selected, its details are extracted via a call to the getJob method Q. The job is stored in a Bundle, put into an Intent ©, and subsequently sent to the ShowJob Activity for display and/or editing O. Note the use of SHOWJOB as the last parameter of the startActivityForResult method. When this called Activity returns, that parameter will help the caller understand the context of the data when the onActivityResult method is invoked Q and the return code checked. To obtain the changed JobEntry, we need to extract it from the Intent with a call to getExtras(), which returns a Bundle. This Bundle is turned into a JobEntry instance via the static fromBundle method of the JobEntry class. To update the list of jobs to reflect this changed JobEntry, call the replace method ©.

Now that we can view and select the job of interest, it is time to look at just what we can do with that job. Before diving in to the next section, be sure to review the ManageJobs code carefully to understand how the JobEntry information is passed between the two activities.

0 0

Post a comment