title: Parent fragment to Child Fragment communication
body: <p>I have been searching and haven't found the best way for nested fragments to communicate with parent fragment. The Android documentation states that:</p>
  
  <blockquote>
    <p>All Fragment-to-Fragment communication is done through the associated Activity. Two Fragments should never communicate directly.</p>
  </blockquote>
  
  <p>Suppose I have a Gallery app, there is a <strong>ViewPagerFragment (parent)</strong> and <strong>ImageFragment(child)</strong> that is used to show images full screen when they are clicked. I need to pass an ArrayList of Files from my parent fragment to the child fragment. What is a proper way to do it?</p>
  
  <p>1) Create a getter for the ArrayList in <strong>parent fragment</strong> and use the <code>getParentFragment()</code> in a <strong>child fragment</strong> to access this method?</p>
  
  <p>2) Implement an interface and go through the Activity, but how will I locate the <strong>child fragment</strong> from the Activity if it doesn't have an ID?</p>
  
  <p>3) Or use this in <strong>parent fragment</strong>:</p>
  
  <p><code>ChildFragment fragment =(ChildFragment)getChildFragmentManager().findFragmentById(R.id.child_fragment_id);
  </code></p>
  
  <p>And just use a setter in <strong>child fragment</strong>.</p>
  
  <p>But again how do I get the ID of the childFragment?</p>
  
  <p>Thanks everyone in advance</p>