Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I understand you have two panes (left pane is ListFragment) and these two fragments are held within a FragmentActivity. The fragments are being set in the xml layout for the FragmentActivity. The fragments are available to the FragmentActivity following the onAttach() cycle but this doesn't necessarily mean that the view elements in the child fragment are available yet.</p> <p>First question is where are you trying to set the selected item? In the FragmentActivity or in the ListFragment? It should be handled in the ListFragment in the onResume() method.</p> <p>I take it that based on the selection in the ListFragment you are then populating the right fragment with data for the selection. You will probably want to look at this link which will give you a good example of using listeners to avoid dependancies between the fragment activity and underlying fragments</p> <p><a href="http://developer.android.com/training/basics/fragments/communicating.html" rel="nofollow">http://developer.android.com/training/basics/fragments/communicating.html</a></p> <p>You can then use listeners to handle the selection in the ListFragment and pass the selection to the right fragment. In the right fragment you can check for a selection in the FragmentActivity as well as register the fragment to listen for selections. This way you should cover the situation where the selection is fired before the right fragment has registered as a listener.</p> <p><strong>UDPATE</strong></p> <p>Look at responsive layout design for further information but here are some starting points.</p> <pre><code>/res /values bool.xml /values-sw600dp-land bools.xml </code></pre> <p>Then inside the bools.xml file define a value for isDualPane</p> <pre><code>&lt;resources&gt; &lt;bool name="isDualPane"&gt;[true/false]&lt;/bool&gt; &lt;/resources&gt; </code></pre> <p>Then in your code in the listFragment you can then reference bools resource and know what the layout is. </p> <pre><code>isDualPane = getResources().getBoolean(R.bool.isDualPane); </code></pre> <p>You also have the benefit of using this in any class to know what the layout is and without needing to create dependancies between classes.</p> <p>Here are some links that might help.</p> <p><a href="http://developer.android.com/training/multiscreen/screensizes.html" rel="nofollow">http://developer.android.com/training/multiscreen/screensizes.html</a> http://developer.android.com/training/multiscreen/adaptui.html</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload