Code example for ListFragment

Methods: getActivity, getArguments, onCreate

0
    private ListView mListView;
 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        // Get a handle on our containing activity. 
        mParentActivity = this.getActivity();
 
        // Create our adapter. 
        mAdapter = new ArrayAdapter<GroupData>(mParentActivity, android.R.layout.simple_list_item_1, mGroupList);
 
        // Load our sort type from the arguments. 
        if (getArguments() != null && getArguments().containsKey("sort")) {
            mSortType = getArguments().getString("sort");
        } 
 
        // Load the first set of groups. 
        new GetUserGroupsTask().execute();
    }