Code example for ListFragment

Methods: getArguments, getLoaderManager, onActivityCreated

0
     
    public static final String EXTRA_DEVICE = "device";
     
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getLoaderManager().initLoader(0, getArguments(), this);
    } 
     
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent intent = new Intent(view.getContext(), RecoveryActivity.class);
        intent.putExtra(EXTRA_RECOVERY, (Recovery) parent.getItemAtPosition(position));
        startActivity(intent);
    } 
 
    @Override 
    public Loader<List<Recovery>> onCreateLoader(int arg0, Bundle arg1) {
        Device device = Device.valueOf(arg1.getString(EXTRA_DEVICE));
        return new ExtendedDeviceLoader(getActivity(), device);
    }