title: Using same views twice in two Fragments
body: <p>I have a quiz app with two fragments, for the two quiz modes I have, within a ViewPager. For each fragment, in addition to other things, I dynamically create a list by inflating linearlayouts from XML within a while loop iterating through all the categories. This layout which contains this list is identical in both the modes, it is the rest of the fragment that is different, hence requiring two separate pages. </p>
  
  <p>The problem therefore is that I do this costly process of inflating layouts twice, once within each fragment. I would like to do this only once and use it twice. </p>
  
  <p>Two solutions I've considered:</p>
  
  <ul>
  <li>Using an adapter in the parent activity, accessing this through the
  fragments and subsequently using a ExpandableListView.</li>
  </ul>
  
  <p>Problems:</p>
  
  <ol>
  <li>I use checkboxes to select categories. The two fragments deal with clicks differently. With my limited knowledge I have no clue how achieve this. I understand that I can inflate a custom layout but then how do I set a listener in the fragment? </li>
  <li>Some of my categories are grouped, others are standalone items. How do I remove the arrow in these items? </li>
  </ol>
  
  <p>.</p>
  
  <ul>
  <li>Using an arraylist in the parent activity. Accessing this in each fragment and adding the layouts to the parent this way. </li>
  </ul>
  
  <p>Problems:</p>
  
  <ol>
  <li>Cannot do this as I'm adding the same view twice so I get an error as the specified child already has a parent. (IllegalStateException)</li>
  </ol>
  
  <p>However this does mean I can easily access the CheckBoxes and iterate through settings oncheckedchangedlisteners</p>
  
  <p>Thank you so much in advance :) If you require any more information or anything else just ask!</p>