0

scenario: I have the mainActivity in which it holds the default game list fragment When user clicks an item on the list it should show the FragmentActivity that contains a viewpager with two tabs inside the framelayout basically replacing the default game list fragment.

question: how can I add FragmentActivity to the FrameLayout?

what I have tried:

//this throws an error because the fragment cannot be casted to `FragmentActivity`
Fragment fragment = (NewsTopicsFragment) ft.findFragmentById(R.id.container);

                    //Fragment mNewsTopicsFragment =(Fragment) new NewsTopicsFragment();
                    //mNewsTopicsFragment.setGame(mGame);

                    getActivity()
                        .getSupportFragmentManager().beginTransaction()
                            .replace(R.id.container, mNewsTopicsFragment)
                            .commit();
Emil Reña Enriquez
  • 2,929
  • 1
  • 29
  • 32
  • `FragmentActivity` is component which work as a Activity so it's not possible to add `FragmentActivity` to FrameLayout same as we add Fragments – ρяσѕρєя K Jan 30 '15 at 04:20

1 Answers1

0

You should replace this fragmentActivity by a fragment. You can nest fragments so that shouldn't be a big change and then you'll be able to add the fragment to the frameLayout.

k3v1n4ud3
  • 2,904
  • 1
  • 15
  • 19