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 8315907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:14:11+00:00 2026-06-08T21:14:11+00:00

I have a loading screen, I want to display the loadingMessage1 for 3 secs

  • 0

I have a loading screen, I want to display the loadingMessage1 for 3 secs than shows loading message 2. I only want loading message 2 to appear once, but when I tried to do it, loading message 2 kept getting appended in an endless loop.

So i tried put a count variable to increases after every loading message 2 append, but it doesnt work. where am i going wrong, is there another solution to this?

final TextView loadingMessage1 = (TextView)this.findViewById(R.id.loadingMessage1);
int count = 0;
final Handler handler = new Handler();

if (count == 0){
    handler.post(new Runnable(){    
            @Override
            public void run(){
                loadingMessage1.append("Loading Message 2");
                handler.postDelayed(this, 3*1000L);
            }   
    }); 
    count++;
}
  • 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-08T21:14:12+00:00Added an answer on June 8, 2026 at 9:14 pm

    You are making a mistake on the following line:

    handler.postDelayed(this, 3*1000L);
    

    Here you send to this Runnable object to the handler while handling this. That means when you fist execute the Runnable, on the end you add it again to the handler’s message loop. Thus you obtained an infinite loop. Something of the like will solve your problem:

    final TextView loadingMessage1 = (TextView)this.findViewById(R.id.loadingMessage1);
    int count = 0;
    final Handler handler = new Handler();
    
    handler.postDelayed(new Runnable(){    
            @Override
            public void run(){
                loadingMessage1.append("Loading Message 2");
            }   
    }, 3*1000L); 
    

    EDIT:

    To make all this stuff flexible, do the following:

    // inner class
    class TextChanger implements Runnable {
        private final String message;
    
        public TextChanger(String message) {
            this.message = message;
        }
    
        @Override
        public void run() {
            loadingMessage1.append(message);
        }
    
    }
    

    and then somewhere in your code:

    public static final long TIME_CONSTANT = 3*1000L;
    
    final TextView loadingMessage1 = (TextView)this.findViewById(R.id.loadingMessage1);
    int count = 0;
    final Handler handler = new Handler();
    
    handler.postDelayed(new TextChanger("Whatever 1"), TIME_CONSTANT);
    handler.postDelayed(new TextChanger("Whatever 2"), 2 * TIME_CONSTANT);
    

    and so on. The trick is not to reference this as you did before, because it creates an infinite loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a splash screen to show while the application is loading. I have
Is there a way to have an animated loading screen for my iPhone application
In my android game I want to display a screen when it loads up
I have an app which when opened, displays a splash/loading screen. I had this
I have a block of images that I want to load on my screen.
got a little problem with MBProgressHUD. I have a webview and want to display
I want to display my game on the screen. I started to write a
I want to have a button press display a web page, I use the
Hi I have a webpage that's using classic ASP that I want to display
I'm trying to have a loading screen that pops up as soon as you

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.