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

  • SEARCH
  • Home
  • 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 6354847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:38:48+00:00 2026-05-24T22:38:48+00:00

I recently discovered that since my app is pulling so much data from a

  • 0

I recently discovered that since my app is pulling so much data from a few URLs, it takes about 3-7 seconds for it to load the main layout. So, I made a layout called ‘loading’ to display, which is just simply a TextView that states “Please wait while data is being collected…”. However, when I run my app, it won’t display the ‘loading’ layout. It simply goes black for a while, like it used to before, and then go to the main layout. I tried cleaning the project too, and it still does this. Here’s a portion of my Main.java:

@Override
public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.loading);
    populateArray();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Set up click listeners for all buttons
    View v1 = findViewById(R.id.continueButton);
    v1.setOnClickListener(this);

    View v2 = findViewById(R.id.colorCheck);
    v2.setOnClickListener(this);

    View v3 = findViewById(R.id.terms);
    v3.setOnClickListener(this);
}

populateArray(); is the method that is pulling all the information of the internet. So, I figured, “Why not tell it to set the content view immediately to ‘loading’, have it run populateArray();, then display the main layout?” Obviously, I must be missing something here. Any ideas?

==========================================================================

EDIT: I tried using AsyncTask, but I’m getting a force close. I’m also getting a warning saying the AsyncTask class is never used. Here’s my code:

P.S. ProgressDialog dialog; is a global definition.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dialog = ProgressDialog.show(this, "",
                "Please wait while data is collected...", true);

        // Set up click listeners for all buttons
        View v1 = findViewById(R.id.continueButton);
        v1.setOnClickListener(this);

        View v2 = findViewById(R.id.colorCheck);
        v2.setOnClickListener(this);

        View v3 = findViewById(R.id.terms);
        v3.setOnClickListener(this);
    }

And…

    private class LoadData extends AsyncTask <String[][], String, String> {
        @Override
        protected String doInBackground(String[][]... voidThisArray) {
            String voidThisString = null;
            populateArray();
            return voidThisString;
        }

        @Override
        protected void onPostExecute(String voidThisString) {
            setContentView(R.layout.main);
            dialog.dismiss();
        }

    }

I would give you the LogCat for the force close but for some reason the LogCat isn’t displaying anything…

  • 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-05-24T22:38:48+00:00Added an answer on May 24, 2026 at 10:38 pm

    You want to use an AsyncTask to first: create a ProgressDialog that will display the loading message. Then the AsyncTask will work in the background collecting all of the data.

    Hope that helps.

    private class Task extends AsyncTask<Void,Integer, Void> {
        private ProgressDialog dia;
    
        @Override protected void onPreExecute() {
            dia = new ProgressDialog(MyContext.this);
            dia.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            dia.setMessage("Loading. Please wait...");
            dia.setCancelable(false);
            dia.show();
    
                    // Set up preserver download stuff
            }
    
        @Override protected Void doInBackground(Void... voids) {
            // perform server download stuff
        }
    
        @Override public void onProgressUpdate(Integer... prog) {
            if (prog == null)
                return;
            dia.setProgress(prog[0]);
        }
    
        @Override  protected void onPostExecute(Void voids) {
            // Do any post op stuff
            dia.cancel();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently discovered that some functionality has been changed drastically in the DataGrid since
I have discovered recently that's possible to call anoymous blocks from jdbc like this:
I've recently discovered that my app malfunctions on Win 7 machines because it does
I'm learning C++ (coming from java) and recently discovered that you can pass functions
I recently discovered a pretty big performance issue in my app that was due
We recently discovered that the Google Maps API does not play nicely with SSL.
I recently discovered that when you have a page set to session readonly and
I recently discovered that I can use lambdas to create simple event handlers. I
I recently discovered that a sql query that was running fine earlier is now
I recently discovered that in C++ you can overload the function call operator, in

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.