-2

I am very new in android programming and i am confused, which library should be used.

FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment start_frag = fragmentManager.findFragmentById(R.id.fragment_container);
        if(start_frag == null) {
            start_frag = new CM_youtubePlaylist();
            fragmentManager.beginTransaction().add(R.id.fragment_container, start_frag).commit();
        }

I am stuck in between android.app.FragmentManager and android.support.v4.FragmentManager. Actually i have imported both of them, and now it is showing error, which is quite obvious. What I want to ask, which library should i use and which one is better between both of them?

Fazeel Qureshi
  • 854
  • 9
  • 18

2 Answers2

1

For API >= 14, use getFragmentManager.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Try to change the Fragment type to android.support.v4.app.Fragment to which you are switching. And Let FragmentManager be android.support.v4.app.FragmentManager

Anmol317
  • 1,356
  • 1
  • 14
  • 31