title: Android: How to use getChildFragmentManager() in an ArrayAdapter class?
body: <p>How can i use the method <code>getChildFragmentManager()</code> in a custom adapter that extends <code>ArrayAdapter&lt;&gt;</code> ?</p>
  
  <p>Here's my code if you need to see it:</p>
  
  <p>MyAdapter.java:</p>
  
  <pre><code>public class MyAdapter extends ArrayAdapter&lt;Content&gt; {
  
  
      Context context;
      List&lt;Content&gt; myList;
      public static final String pattern = "(?&lt;=watch\\?v=|/videos/|embed\\/)[^#\\&amp;\\?]*";
      public MyAdapter(Context context, int resource, List&lt;Content&gt; objects) {
          super(context, resource, objects);
  
          this.context = context;
          this.myList = objects;
      }
  
  
      @Override
      public int getCount() {
          if (myList != null)
              return myList.size();
          return 0;
      }
  
      @Override
      public Content getItem(int position) {
          if (myList != null)
              return myList.get(position);
          return null;
      }
  
      @Override
      public long getItemId(int position) {
          if (myList != null)
              return myList.get(position).hashCode();
          return 0;
  
      }
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          Holder holder;
  
          if (convertView == null) {
  
              holder = new Holder();
  
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              convertView = inflater.inflate(R.layout.list_item, null);
  
              holder.contId = (TextView) convertView.findViewById(R.id.content_id);
              holder.contType = (TextView) convertView.findViewById(R.id.type);
              holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
              holder.txtTeaser = (TextView) convertView.findViewById(R.id.teaser);
              holder.imageView = (ImageView) convertView.findViewById(R.id.cover_photo);
              holder.youTubeVideo = (FrameLayout) convertView.findViewById(R.id.youTube_frame);
  
  
              convertView.setTag(holder);
  
          } else {
  
              holder = (Holder) convertView.getTag();
  
          }
  
  
          Content content = getItem(position);
  
          holder.contId.setText(content.getId());
          holder.contType.setText(content.getType());
          holder.txtTitle.setText(content.getTitle());
          holder.txtTeaser.setText(content.getTeaser());
          Picasso.with(context).load(Uri.parse(content.getImageUrl())).into(holder.imageView);
  
          if(content.getCoverVideo() != null &amp;&amp; !content.getCoverVideo().equals("")){
              String cover_video = content.getCoverVideo();
              Pattern compiledPattern = Pattern.compile(pattern);
              Matcher matcher = compiledPattern.matcher(cover_video);
              if(matcher.find()){
                  cover_video =  matcher.group();
              }
              Bundle youTubeBundle = new Bundle();
              youTubeBundle.putString("link", cover_video);
  
              FragmentManager manager = getChildFragmentManager(); // &lt;------ Can't resolve method
  
              FragmentTransaction transaction = manager.beginTransaction();
  
              ArticleYouTubeFragment youtubeFragment = new ArticleYouTubeFragment();
              youtubeFragment.setArguments(youTubeBundle);
              transaction.replace(R.id.list_youTube_frame, youtubeFragment);
              transaction.commit();
          }
  
          return convertView;
      }
  
      private class Holder {
  
          TextView contId;
          TextView contType;
          TextView txtTitle;
          TextView txtTeaser;
          ImageView imageView;
          FrameLayout youTubeVideo;
  
      }
  }
  </code></pre>
  
  <p>Thanks in advance.</p>