Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8173385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:07:57+00:00 2026-06-06T22:07:57+00:00

Splash I have main activity UI startup operations that take between 5-10 seconds (that

  • 0

Splash

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.

A good solution to the splash screen is provided below

  • which is to first set setContentView(R.layout.splash),
  • then do the necessary main UI processing (on UI thread but with main view that is not visible)
  • and when that is ready show setContentView(R.layout.main)

Android Splash Screen before black screen


Splash with Fragments

I’m also using fragments, which normally require setContentView(R.layout.main) to be called before fragment instantiation – so that the fragment manager could find the view stubs in R.layout.main to inflate the fragments into (strictly speaking view stubs are a different thing).

  • But I cannot call setContentView(R.layout.main) before creating the fragments, because that replaces the splash screen with the (not-yet-ready) main screen.
  • My fear is that what I want to do cannot be done?
  • Unfortunately, there is no overload like fragmentTransaction.add(viewNotViewId, fragment);

Almost-Answer

Here’s all but the key, which is that setContentView is called before the fragment transactions:
How do I add a Fragment to an Activity with a programmatically created content view

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:08:00+00:00Added an answer on June 6, 2026 at 10:08 pm

    You could try replacing your fragments in your FragmentActivity, here is the idea partially coded:
    Suppose you have your fragments layout like this (main.xml):

    <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal">
    
        <LinearLayout android:id="@+id/waiting" ...>
        </LinearLayout>
    
        <!-- hidden layout -->
        <LinearLayout>
            <LinearLayout android:id="@+id/layout_list_items" ...>
            </LinearLayout>
            <LinearLayout android:id="@+id/layout_detail" ...>
            </LinearLayout>
        </LinearLayout>
    
    </LinearLayout>
    

    And your FragmentActivity like this:

    public class FragmentsActivity extends FragmentActivity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            this.setContentView(R.layout.main);
    
            Fragment fragA = new WaitingTransaction();
    
            FragmentTransaction fragTrans = this.getSupportFragmentManager().beginTransaction();
            fragTrans.add(R.main.waiting, fragA);
            fragTrans.commit();
        }
    
        private void afterProcessing(){
    
                    //show hidden layout and make the waiting hidden through visibility, then add the fragment bellow...
            FragmentTransaction fragTrans = this.getSupportFragmentManager().beginTransaction();
            fragTrans.add(R.main.layout_list_items,
                              new FragmentList());
            fragTrans.replace(R.main.layout_detail,
                              new FragmentB());
            fragTrans.commit();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a label on a splash screen that is displayed for 4 seconds.
I have an app that displays a splash screen. The splash screen activity creates
I have two activities: A: a Splash Screen B: the Main activity When the
I have an application with like 400 records in the database, I have splash
I have the following issue: I have a splash like window coming with my
I have a splash screen on the application and on that form. I have
I have this extremely simple splash page here: http://iph0wnz.com It has the main graphic
So I'd like to have a full screen splash (320x480 - without status pane
I have the main activity which launches a loading screen activity. When the loading
I have a question that I have a splash screen in my android app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.