Search code examples
androidandroid-fragmentsandroid-listfragment

How to get 2 fragments of the same class with different content?


I have class:


public class ConferenceListFragment extends SherlockListFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        DBAdapter dbAdapter = new DBAdapter(new DBHelper(getSherlockActivity()));       
        //How to get veriable "FLAG_BOOLEAN" ?
        List list = dbAdapter.getListItemInfoArray(FLAG_BOOLEAN);

        dbAdapter.close();

        CustomListAdapter adapter = new CustomListAdapter(getActivity(), list);
        setListAdapter(adapter);        
    }
}

Depending on the variable FLAG_BOOLEAN, i get different data from DB. So can i send this FLAG from Activity to fragments?


Solution

  • You should use setArguments in the activity to pass them to the fragments and getArguments from within the fragments to retrieve them.