Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>According to the android documentation of fragments: <strong>A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).</strong></p> <p><a href="http://developer.android.com/guide/components/fragments.html" rel="nofollow">http://developer.android.com/guide/components/fragments.html</a></p> <p>what i understood from your question is that you want to the content of your fragement <code>viewer</code> at run-time. a possible solution which i can suggest for this is: Instead of your four classes extending <code>Activity</code>, extend <code>Fragment</code>, each having its own layout. Modify the main layout file to look something like this:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;fragment android:name="com.example.news.ArticleListFragment" android:id="@+id/list" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" /&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/viewer" android:layout_weight="2" android:layout_width="0dp" android:layout_height="match_parent" &gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>the FrameLayout will basically act as a container for your fragments, which you can dynamically load at run-time(by clicking the ListView). This tutorial will help you out with it:</p> <p><a href="http://developer.android.com/training/basics/fragments/fragment-ui.html" rel="nofollow">http://developer.android.com/training/basics/fragments/fragment-ui.html</a></p> <p>Hope my answer helps you in some way.</p>
 

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