Search code examples
androidandroid-fragmentsnavigation-drawerandroid-listfragment

Android displaying listFragment in a navigation drawer


It seems for me that the replace method for fragments does not work with list fragments. This code gives me an error:

mFragmentManager.beginTransaction().replace(R.id.content_frame, mFragment).commit();

How do I display list fragments in a navigation drawer? Is there any other way?

The error I receive is that:

The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, ListFragment)

It says that it's not applicable. When I changed the list fragment class into a fragment only, my problem is that I cannot set also the adapter for a list view which is the setListAdapter. Can someone help me please?


Solution

  • mFragment is a Fragment and you have to use a ListFragment as a parameter.