I have this Activity which at first shows a Fragment with a list of elements. This works perfectly with this code:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.list_act);
if(null == savedInstanceState)
{
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
ListFragment glfragment = new ListFragment();
fragmentTransaction.add(R.id.listfrag1, glfragment);
fragmentTransaction.commit();
}
}
Well I have a ListFragment
and a DetailFragment
. But I don't know how to do the transition when I click an element of the list. I know the fragmentTransaction.replace()
, but I don't know WHEN to call it.
I thought I should use the OnListItemClick()
inside the ListFragment
, but I don't know how to use the FragmentManager
inside the Fragment and not in the main Activity... Also I want to "export" some data to the DetailFragment
as if it was a Intent, but it's not.