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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:47:56+00:00 2026-05-23T14:47:56+00:00

i have a problem in android, first i wanted to have a button which

  • 0

i have a problem in android, first i wanted to have a button which i move every 2 secs to a different place on the screen, but i couldn’t do that (if anyone knows how that would be very helpful).
Anywayz my other way was to make 5 different buttons in different locations and move with the setVisibility() function, but it crashes in the middle i dont know why, here’s the code:

final ImageButton[] face = new ImageButton[5];

    face[0] = (ImageButton) findViewById(R.id.ImageButton1);
    face[1] = (ImageButton) findViewById(R.id.ImageButton2);
    face[2] = (ImageButton) findViewById(R.id.ImageButton3);
    face[3] = (ImageButton) findViewById(R.id.ImageButton4);
    face[4] = (ImageButton) findViewById(R.id.ImageButton5);

    for(int i=0;i<5;i++)
    {
        face[i].setVisibility(View.GONE);
    }



    Thread timer=new Thread() {
        public void run(){
            for(int i=0;true;i++)
            {
                if(i==5)
                {
                    i=0;
                }
                Log.v("VISIBLE AT I = ",Integer.toString(i));
                face[i].setVisibility(View.VISIBLE);
                try {
                    sleep(2000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    Log.v("CATCH","CATCH");
                    e.printStackTrace();
                }
                //Log.v("SLEPT","SLEPT");
                face[i].setVisibility(View.INVISIBLE);  // IT CRASHES HERE
                Log.v("INVISIBLE AT I = ",Integer.toString(i));
            }
        }
    };

    timer.start();

If anyone can help me that would be great, thanks.

  • 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-23T14:47:57+00:00Added an answer on May 23, 2026 at 2:47 pm

    Have you thought of doing this with an animation? If you’re targeting Honeycomb, you can use a property animation; for earlier platforms you can use a view animation.

    As for your crashes, you can only modify UI elements from the UI thread, not from a separate thread. You’d need to signal back, or use one of the (very good) helpers to handle this, such as AsyncTask.

    See: http://developer.android.com/resources/articles/painless-threading.html

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

Sidebar

Related Questions

I have to make a simple layout in android but have problem with the
I still have problem with fetching first location on android. I am using Criteria
I have a problem with back button functionality in an Activity of Android. The
Hello I started trying to develop Android applications today, but I have a problem:
I have a problem with my first android widget... I am doing like this:
I am new to android and making my first application. I have a problem
I have an interesting problem being reported to me from an android application I
I have a simple problem for Android. I'd like to create an n by
I have been struggling with a unit testing problem on Android for a while
i have a problem with binding a service to an activity in Android. The

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.