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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:21:28+00:00 2026-05-15T23:21:28+00:00

Hey. I just started with Android. I’m using the ViewFlipper layout with 2 LinearLayouts.

  • 0

Hey. I just started with Android. I’m using the ViewFlipper layout with 2 LinearLayouts. First layout has a button that switches to the second layout. I would like to add a timer that would switch to the first layout after 3000ms.
I tried with a Thread but it did not work (can not communicate with UI element of other thread).

My code:

public class Test extends Activity {

ViewFlipper f;
LinearLayout l1;
LinearLayout l2;
Button b1;

Thread s;

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

    f = (ViewFlipper) findViewById(R.id.f);
    l1 = (LinearLayout) findViewById(R.id.l1);
    l2 = (LinearLayout) findViewById(R.id.l2);
    b1 = (Button) findViewById(R.id.b1);

    updateSwitch = new Thread() {
        @Override
        public void run() {
            try {sleep(3000);
            } catch (InterruptedException e) {
            } finally {f.showPrevious();}
        }
    };

    b1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            f.setAnimation(AnimationUtils.loadAnimation(v.getContext(), R.anim.push_left_in));
            lFlipper.showNext();
            updateSwitch.start();
        }
    });
}

}

My guess is that I need some kind of handler that would connect a new Thread with the main thread.
Please update my code. Thx 10x.

  • 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-15T23:21:29+00:00Added an answer on May 15, 2026 at 11:21 pm

    You need to read a technical article about Updating the UI from a Timer

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

Sidebar

Related Questions

Hey I just started dabbling with android programming, and from my short period of
Hey, I've just started learning JavaScript and I'm making a little script that generates
Hey all. I just started looking into the cocos2d library. I've heard that it's
Hey, I am completely new to Rails and just started created my first Project,
Hey, I just started wondering about this as I came upon a code that
Hey guys, I just started learning C++ and I have this code that I
hey guys I just started trying to convert my query structure to PDO and
hey all, just getting started on hadoop and curious what the best way in
hey all, I'm just getting started with c3p0 for database connection pooling. It's attaching
Hey just curious is there a function that you can use to divide 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.