Code example for ListFragment

Methods: getActivity, getArguments, onCreate, setListAdapter

0
    private ReportsAdapter adapter;
    private Handler mMessageQueueHandler = new Handler();
     
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        reloadFromArguments(getArguments());
    } 
 
    public void reloadFromArguments(Bundle arguments) {
        // Teardown from previous arguments 
        setListAdapter(null);
         
        obtainReports(); 
        adapter = new ReportsAdapter(getActivity()); 
         
        setListAdapter(adapter);
    } 
     
    private ResultReceiver reports_receiver = new ResultReceiver(null) {
	    @Override 
	    protected void onReceiveResult(int result_code, Bundle bundle) { 
	    	if (result_code > 0 ) { 
	    		Log.v(TAG,"received reports! received reports! received reports! received reports! "); 
	    		ArrayList<Hashtable<String,Object>> reports = (ArrayList<Hashtable<String,Object>>)bundle.get(DownloadReportsCenter.REPORTS_KEY); 
	    		adapter.setData(reports); 
	    		if (reports == null) Log.v(TAG, "REPORTS NULL REPORTS NULL REPORTS NULL REPORTS NULL REPORTS NULL REPORTS NULL "); 
	    		else Log.v(TAG,"reports size reports size reports size reports size >>>> " + reports.size()); 
	    		adapter.notifyDataSetChanged(); 
	        } 
	    	DownloadReportsCenter.getInstance(getActivity()).removeResultReceiver(this); 
	    } 
	}; 
     
    private void obtainReports(){ 
    	Log.v(TAG,"OBTAINING REPORTS OBTAINING REPORTS OBTAINING REPORTS OBTAINING REPORTS OBTAINING REPORTS OBTAINING REPORTS ");
    	final DownloadReportsCenter download_reports_center = DownloadReportsCenter.getInstance(getActivity());
		download_reports_center.registerResultReceiver(reports_receiver);
		download_reports_center.download();
    } 
 
    @Override