Note that there are some explanatory texts on larger screens.

plurals
  1. POOrientation change from dual-pane to single-pane
    primarykey
    data
    text
    <p>orientation change between different layouts for landscape and portrait seems to be easy, however I cannot find a solution for my current situation.</p> <p>I want to use a dual-pane layout with two fragments in landscape mode</p> <p>res\layout-land\dashboard_activity.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" &gt; &lt;fragment class="xxx.DashboardFragment" android:id="@+id/master_frag" android:layout_width="@dimen/timeline_size" android:layout_height="match_parent"/&gt; &lt;fragment class="xxx.TaskInstanceFragment" android:id="@+id/details_frag" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and a single-pane layout in portrait mode</p> <p>res\layout\dashboard_activity.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;fragment class="xxx.DashboardFragment" android:id="@+id/master_frag" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/FrameLayout&gt; </code></pre> <p>I want to note that the DashboardFragment consists of a ViewPager. Do not know if it is of importance.</p> <p>Now, when I change the orientation from landscape (dual) to portrait (single) the app crashes, because it wants to update the <code>details_frag</code>. When I start the activity in portrait, it works, only switching from landscape to portrait makes problems.</p> <p>In the activity there is the following code:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dashboard_activity); Fragment frag = getSupportFragmentManager().findFragmentById(R.id.details_frag); mDualFragments = frag != null; /* .. */ } </code></pre> <p>Now the <code>FragmentManager</code> still finds the details fragment when I switch to portrait mode and thus <code>mDualFragments</code> is still true but should be false, which leads to a later call to a method in the details fragment.</p> <p>So, why is this? :)</p> <p>Regards, Konsumierer</p>
    singulars
    1. This table or related slice is empty.
    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. 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