Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The typical mechanism is to use <a href="http://developer.android.com/reference/android/app/FragmentManager.html#findFragmentByTag(java.lang.String)" rel="nofollow noreferrer"><code>FragmentManager.findFragmentByTag()</code></a> . You use this and add tags to your fragments (or the alternative for id's). This way you can determine what fragments are currently being managed. Then, once you have a handle to a present fragment (findFragmentByTag returns non-null), you can use <a href="http://developer.android.com/reference/android/app/FragmentManager.html#beginTransaction()" rel="nofollow noreferrer"><code>FragmentManager.beginTransaction()</code></a> to start a FrgamentTransaction and remove / add the necessary fragments. Working in this way will allow you to avoid the 're-adding' process for the fragment you want to keep. </p> <p>What I'd probably do is have code like so: (warning psuedo code)</p> <pre><code>Fragment pane1 = FragmentManager.findFragmentByTag("myFragmentPane1"); Fragment pane2 = FragmentManager.findFragmentByTag("myFragmentPane2"); setupScreen(pane1, pane2); </code></pre> <p>You should also consider sub-classes of your class instead of having 'everything in one class'. You have a fairly obvious case of Martin Fowler's <a href="http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html" rel="nofollow noreferrer">Replace Conditional with Subclass</a>. Otherwise, I fear this is going to be incredibly hard to manager when you add another screen.</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