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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:14:51+00:00 2026-05-17T00:14:51+00:00

I have an imageView and want it to work like this: ImageViewer visible 5

  • 0

I have an imageView and want it to work like this:

ImageViewer visible

5 second pause

image view invisible

5 second pause

ImageViewer visible

and so on …

How do I do that? I have tried sleep but it freezes the whole program in 5 seconds. I just want to affect my imageView.

  • 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-17T00:14:52+00:00Added an answer on May 17, 2026 at 12:14 am

    I’m not an Android programmer, but, as a general advice, I’d say you should perform the sleep, better said the waiting, on another thread and execute at the end of the waiting period, on the main thread, a method that toggles the visibility of your imageview.

    Getting into more specific detail, I’d say you must use a Handler object because you cannot update most UI objects while in a separate thread. When you send a message to the Handler it will get saved into a queue and get executed by the UI thread as soon as possible:

    public class MyActivity extends Activity {
    
    // Handler needed for callbacks to the UI thread
    final Handler mHandler = new Handler();
    
    // Create runnable for posting
    final Runnable mUpdateUIState = new Runnable() {
        public void run() {
            updateUIState();
        }
    };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        [ . . . ]
    }
    
    protected void startToggle() {
    
        // Fire off a thread to do the waiting
        Thread t = new Thread() {
            public void run() {
                Thread.Sleep(5000);
                mHandler.post(mUpdateUIState);
            }
        };
        t.start();
    }
    
    private void updateUiState() {
    
        // Back in the UI thread -- toggle imageview's visibility
        imageview.setVisibility(1 - imageview.getVisibility());
    }
    }
    

    or, a snippet of a shorter version,

    Handler handler = new Handler(); 
        handler.postDelayed(new Runnable() { 
             public void run() { 
                  imageview.setVisibility(1 - imageview.getVisibility());
             } 
        }, 5000); 
    

    using the postDelayed method, that incorporates the delay within the message posting logic.

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

Sidebar

Related Questions

I have a code like that this, I want to delete the imageview after
I have a ImageView and draw some things on that view. Now I want
I want to show an image view for three like on/off,if any one have
I have an Imageview(like a Magazine page).When i swype in to that image then
I have a 16x16 pixel image that I want to display in an UIImageView.
So, I have an imageview that should display an arbitrary image, a profile picture
I have a vew, received by: (ImageView) findViewById(R.id.photo) That view currently has a bitmap
Why doesn't this UIView layout code work as I want? Background: I have a
I want to use UITableViewCells within my application which have an image, and that
I want a Layout like this: But my code doesn't work. I can't achieve

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.