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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:02:45+00:00 2026-05-26T16:02:45+00:00

I wanted my app to had a fading picture first before going into another

  • 0

I wanted my app to had a fading picture first before going into another page using threads. Below is the code i used and it worked well for me. However, it stops in the white page at the end of the thread. What will i do so that it will go to the next activity without clicking on anything? Or after the page turns white, what code should i use so that it will go now to the next activity?

package com.kfc;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.view.*;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

public class Intro extends Activity {
    LinearLayout screen;
    Handler handler = new Handler();
    int i;
    Intent intent;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.introxml);

        screen = (LinearLayout) findViewById(R.id.myintro);

        (new Thread(){
            @Override
            public void run(){
                for(i=0; i<255; i++){
                    handler.post(new Runnable(){
                        public void run(){
                            screen.setBackgroundColor(Color.argb(255, i, i, i));
                        }
                    });
                    // next will pause the thread for some time
                    try{ sleep(10); }
                    catch(Exception e){ break; }
                }
                for(i=255; i>0; i--){
                    handler.post(new Runnable(){
                        public void run(){
                            screen.setBackgroundColor(Color.argb(255, i, i, i));
                        }
                    });
                    // next will pause the thread for some time
                    try{ sleep(10); }
                    catch(Exception e){ break; }
                }
                startActivity(new Intent(Intro.this,NewKFCActivity.class));
            }
        }).start();
    }
}
  • 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-26T16:02:46+00:00Added an answer on May 26, 2026 at 4:02 pm

    After the for loop exits. Add the code to start a new activity.

    startActivity(new Intent(Intro.this,NewACtivity.class));
    

    You need to put it outside the for loop. If you put it after start method, it will execute before the thread is completed. You may also need to scope the ‘this variable’ using Intro.this. Also remember to add the new activity in the manifest file as

    <activity android:name=".NewActivity"/>
    

    Just use this

    screen = (FrameLayout) findViewById(R.id.layout);
    (new Thread(){
        @Override
    public void run(){
        for(i=0; i<255; i++){
            handler.post(new Runnable(){
                public void run(){
                    screen.setBackgroundColor(Color.argb(255, i, i, i));
                }
            });
            // next will pause the thread for some time
            try{ sleep(100); }
               catch(Exception e){ break; }
            }
            startActivity(new Intent(TabTester.this,NewKFCActivity.class));
        }
    }).start();
    

    this pointer should point to the Intro activity object. But inside the thread, this will refer to the the current thread object(am not sure to what it point exactly) so you need to scope it using ‘Intro.this’ which mean ‘use this that points to the Intro activity’

    You background picture will be overwritten when you use setBackgroundColor to the same view. A way to do this will be to use to layouts, the outer layout will have the background picture and the inner layout will be the one that has setBackgroundColor applied to.
    Eg:

    You also need to alter the code

    screen.setBackgroundColor(Color.argb(255, i, i, i));
    

    to

    screen.setBackgroundColor(Color.argb(120, i, i, i));
    

    The alpha value is set to 255 which means opaque and will not show the background image.

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

Sidebar

Related Questions

I wanted to deploy my app into my local server using apache and passenger.
I had not run into this before but I wanted to know if it's
I wanted to wire the Google App Engine user service in Spring by first
I had a class called ReportsViewController in my iPhone app. I wanted to restore
I wanted to see if anyone had any experience or tips on using timers
I have built part of my app and wanted to test it out. All
I wanted to develop a Django app and one of the functionalities I'd like
I wanted to implement a search feature for my web app. I choose Haystack
I wanted to add crash reporting capabilities to my iPhone app. Kind of the
Just wanted to know if overriding UITabBarController would get my app rejected? Is it

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.