title: Create YouTubePlayerSupportFragment programmatically (Android)
body: <p>I need create YouTubePlayer dynamically, <strong>I can't</strong> extends on YoutubeBaseActivity. So I need create only <strong>YouTubePlayerSupportFragment</strong>. I tried do it like this:</p>
  
  <p><strong>container_more_info_item</strong> - it my linearLayout</p>
  
  <pre><code>//create video
          for(int j = 0; j &lt; 5; j++) {
              final YouTubePlayerSupportFragment ysF = new YouTubePlayerSupportFragment();
              ysF.initialize("AIzbSyAT5C-xs5YG1HzG69Fn__PHq9DHXBuKpws", new YouTubePlayer.OnInitializedListener() {
                  @Override
                  public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                      youTubePlayer.cueVideo("IjUlQU6yifk");
                  }
  
                  @Override
                  public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
  
                  }
              });
  
  //this line error, because ViewGroup can not be applied com.google.android.youtube.player.YouTubePlayerSupportFragment
              container_more_info_item.addView(ysF);
          }
  </code></pre>
  
  <p>And now I'm stuck and can't come up with something</p>
  
  <p><strong>UPD:</strong></p>
  
  <p>I use FragmentManager, but I have this message:</p>
  
  <blockquote>
    <p>Cannot resolve method 'add(int, com.google.android.youtube.player.YouTubePlayerSupportFragment)</p>
  </blockquote>
  
  <pre><code> //create video
          for(int j = 0; j &lt; 5; j++) {
              final YouTubePlayerSupportFragment ysF = new YouTubePlayerSupportFragment();
              ysF.initialize("AIzaSyAT5C-xs5YG1HzG69Fn__PHq9DHXBuKpws", new YouTubePlayer.OnInitializedListener() {
                  @Override
                  public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
                      youTubePlayer.cueVideo("IjUlQU6yifk");
                  }
  
                  @Override
                  public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
  
                  }
              });
  
              LinearLayout ll = new LinearLayout(this);
              ll.setOrientation(LinearLayout.HORIZONTAL);
  
              ll.setId(j);
  
              FragmentManager fragmentManager = getFragmentManager();
              FragmentTransaction fragTransaction = fragmentManager.beginTransaction();
  //Cannot resolve method 'add(int, com.google.android.youtube.player.YouTubePlayerSupportFragment)
              fragTransaction.add(ll.getId(), ysF);
              fragTransaction.commit();
  
              container_more_info_item.addView(ll);
          }
  </code></pre>