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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:40:29+00:00 2026-06-13T06:40:29+00:00

Continuously changing imageview image on start of activity. Will it be possible without using

  • 0

Continuously changing imageview image on start of activity. Will it be possible without using Thread?if not at least tell me how to use Thread properly and how should I initiate it. Please.,

It’s for a whack a mole like android game.


I tried to do simple display of random text but did not work.

public class NewGame extends Activity {

    gameThread gameOn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newgame);

        hView = (TextView) findViewById(R.id.HammersText);
        gameOn = new gameThread();
        gameOn.start();
    }
}

public class gameThread extends Thread
{
    NewGame gameOn;

    public void run() {
        super.run();

        Random ramhole = new Random();
        int hole = ramhole.nextInt(8);

        Random ramletter = new Random();
        int letter = ramletter.nextInt(26);

        gameOn = new NewGame();

        gameOn.hView.setText("Hole = "+hole+"Letter = "+letter);
    }

}

Please help me out on 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-13T06:40:30+00:00Added an answer on June 13, 2026 at 6:40 am

    Use a countdownTimer instead of Thread

    new CountDownTimer(9000000, 5000) {
    
     public void onTick(long millisUntilFinished) {
           Random ramhole = new Random();
            int hole = ramhole.nextInt(8);
    
            Random ramletter = new Random();
            int letter = ramletter.nextInt(26);
            hView.setText("Hole = "+hole+"Letter = "+letter);
     }
    
     public void onFinish() {
       //Restart timer if you want.
     }
    }.start();
    

    You can still do with Threading but its a overkill for what you are trying to do.
    Also in your case, you cannot do

    gameOn = new NewGame();  
    

    Activity always needs to be initialized by framework. And setText api should always be called from Ui thread. Maybe that is why your app is not working

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

Sidebar

Related Questions

I'm using tail -f to print the content of a continuously changing file. When
I have created a desktop application which continuously changes the image on a fixed
I want to rotate imageview with continuously looping on android.my code rotate is working
I'm running an infinite loop of a color changing background on my website using
I have a team that will be using CruiseControl for continuous integration, and CC
I continuously find places where I need to use the <br /> tag because
I have a variable myVariable which is continuously changing. At some point I want
I'm making an Android game, and I'll need a continuously running thread for basically
Im trying to continuously send small UDP-packets (8 byte) as fast as possible from
I have created a datagrid in WPF which has cell values continuously changing, But

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.