Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd fragments before main activity shows main content view
    primarykey
    data
    text
    <h3>Splash</h3> <p>I have main activity UI startup operations that take between 5-10 seconds (that need to be handled on the main UI thread) - so I would like to use a splash screen rather than the default black or non-responsive main UI. </p> <p>A good solution to the splash screen is provided below</p> <ul> <li>which is to first set <code>setContentView(R.layout.splash)</code>,</li> <li>then do the necessary main UI processing (on UI thread but with main view that is not visible)</li> <li>and when that is ready show <code>setContentView(R.layout.main)</code></li> </ul> <p><a href="https://stackoverflow.com/questions/10967532/android-splash-screen-before-black-screen">Android Splash Screen before black screen</a></p> <hr> <h3>Splash with Fragments</h3> <p>I'm also using fragments, which normally require <code>setContentView(R.layout.main)</code> to be called before fragment instantiation - so that the fragment manager could find the view stubs in <code>R.layout.main</code> to inflate the fragments into (<em>strictly speaking view stubs are a different thing</em>).</p> <ul> <li>But I cannot call <code>setContentView(R.layout.main)</code> before creating the fragments, because that replaces the splash screen with the (not-yet-ready) main screen.</li> <li>My fear is that what I want to do cannot be done? </li> <li>Unfortunately, there is no overload like <code>fragmentTransaction.add(viewNotViewId, fragment);</code></li> </ul> <hr> <h3>Almost-Answer</h3> <p>Here's all but the key, which is that <code>setContentView</code> is called before the fragment transactions: <a href="https://stackoverflow.com/questions/5159982/how-do-i-add-a-fragment-to-an-activity-with-a-programmatically-created-content-v">How do I add a Fragment to an Activity with a programmatically created content view</a></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.
 

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