Listing 1215 Manage Jobsjava implements the Manage Jobs Activity

package com.msi.manning.UnlockingAndroid;

// multiple imports omitted for brevity, see full source public class ManageJobs extends Activity implements OnItemClickListener { final int SHOWJOB = 1 ; Prefs myprefs = null; JobList _joblist = null; ListView jobListView; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle) ; setContentView(R.layout.managej obs); myprefs = new Prefs(this.getApplicationContext()); TextView tv =

(TextView) findViewByld (R. id. statuslabel) ;

Connect TextView to UI

A Parse the data in storage

_joblist = JobList.parse(this.getApplicationContext()); if (_j oblist == null) {

_joblist = new JobList(this.getApplicationContext()) ;

Handle a bad parse

tv.setText("There are No Jobs Available"); } else {

tv.setText("There are " + _joblist.getJobCount() + }

jobListView = (ListView) findViewByld (R. id. j oblist) ; <1-

ArrayAdapter<JobEntry> adapter = new ArrayAdapter<JobEntry>(this, android.R.layout.simple_list_item_1, _joblist.getAllJobs()); <

j obListView. setAdapter (adapter) ; <1- Connect the j obListView. setOnI temClickListener (this) ; <|_ list with the j obListView. setSelection (0) ; Process dataevents

0 0

Post a comment