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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:20:56+00:00 2026-05-27T05:20:56+00:00

I want to display 3 colors in my activity screen layout without any user

  • 0

I want to display 3 colors in my activity screen layout without any user interaction with a time interval. for example for each 3 seconds one color should be displayed in my activity screen.
I tried with Thread.sleep(); It is showing the last color only after a long sleep.

    screenLayout=(LinearLayout)findViewById(R.id.screenLayout);  

    screenLayout.setBackgroundColor(Color.RED);
    Log.e("","RED COLOR DISPLAYING..");
    try {
        Thread.sleep(7000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    screenLayout.setBackgroundColor(Color.GREEN);
    Log.e("","GREEN COLOR DISPLAYING..");

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }

    screenLayout.setBackgroundColor(Color.BLUE);

but it didnt work. Could any one please tell me the way to do this.

  • 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-27T05:20:57+00:00Added an answer on May 27, 2026 at 5:20 am

    you can do like this way using Handler and Runnable object

    private Handler handler;
    private LinearLayout linear;
    private int i= 0;
    private Runnable runnable = new Runnable(){
    
        @Override
        public void run() {
            if(i>2)
                i=0;
            else
                i++;
            switch(i){
            case 0:
                linear.setBackgroundColor(Color.BLACK);
                break;
            case 1:
                linear.setBackgroundColor(Color.RED);
                break;
            case 2:
                linear.setBackgroundColor(Color.GREEN);
                break;
            }
    
            handler.postDelayed(runnable, 3000);
        }
    
    };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test7);
        linear = (LinearLayout)findViewById(R.id.main_linear);
        linear.setBackgroundColor(Color.BLACK);
        handler = new Handler();
        handler.post(runnable);
    }
    

    This is the example only but you can implement from this example

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

Sidebar

Related Questions

I want an application in android without any GUI or activity. In my case,
I want to display multiple colors in progressbar. for example, Lets say there are
In one of my app's user interfaces i want my app display a scrolling
I want to display texts in UITextView with different colors and underline some of
I want a layout such that user can toggle between listview and mapview and
I want to display a line of text with two different colors (black and
I have written a code, which is auto-logout when user doesn't perform any activity.
I want to display questions on my blog in red in color and answers
I want display data from database in Listbox...Here is my code, It is not
i want display 1 record from colums zodys , I'm programint in C# I

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.