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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:37:51+00:00 2026-06-11T05:37:51+00:00

In my Android app, I’d like to display several images on the screen in

  • 0

In my Android app, I’d like to display several images on the screen in sequence, waiting for a touch event (a single tap) to go to the next one. I saw here that one way to do this should be:

public class LoadImage extends Activity {
    private Thread thread; //defined inside the activity

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_load_image);

        [get an image and create a bitmap from it]

        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        imageView.setImageBitmap(bitmap);

        thread = new Thread() {
            @Override
            public void run() {
                try {
                    synchronized(this) {
                        wait(100000000); //large number
                    }
                }
                catch(InterruptedException ex) {                    
                }         
            }
        };
        thread.start();    
   }

    @Override
    public boolean onTouchEvent(MotionEvent evt) {
        if (evt.getAction() == MotionEvent.ACTION_DOWN) {
            synchronized (thread) {
                thread.notifyAll();
            }
        }
        return true;
    }
}

However, this code appears to just skip the waiting and immediately jump to the last image. What’s wrong with it, and/or is there a better 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-06-11T05:37:52+00:00Added an answer on June 11, 2026 at 5:37 am

    By default, event listeners in Android are for waiting – you don’t have to provide any delay.

    Simply set the onTouchEvent(...) listener on the ImageView and show the first bitmap. When the ImageView is touched, show the next bitmap and so on. All you have to do is keep a count of how many touches there have been in order to know which image to show (image 1, 2, 3, 4 etc).

    Example…

    public class LoadImage extends Activity {
    
        int imageNumber = 1;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_load_image);
    
            //get an image and create a bitmap from it
    
            ImageView imageView = (ImageView) findViewById(R.id.imageView);
            imageView.setImageBitmap(bitmap);
    
       }
    
        @Override
        public boolean onTouchEvent(MotionEvent evt) {
            if (evt.getAction() == MotionEvent.ACTION_DOWN) {
                imageNumber++;
                switch (imageNumber) {
                    case 2:
                        // show image 2
                        break;
                    case 3:
                        // show image 3
                        break;
                    ...
                }
                return true;
            }
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Android app Transdroid offers several home screen widgets. Every AppWidget has 2 'buttons'
My Android app needs to display a full-screen bitmap as a background, then on
My Android app opens images and makes manipulations on them. My Activity requests an
My Android app, which uses a TabActivity to display its contents, has 4 tabs
My android app has a drop down List,From where user can change language like
My Android app is calling .NET web method and it returns a single string.
My Android app has a ContactsList activity in which I simply display a list
My android app needs to run through a sequence of events as in a
My android app supports all screen sizes, but sometimes I need to dynamically load
My android app currently has two layouts for its splash screen, portrait and landscape.

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.