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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:43:33+00:00 2026-06-15T01:43:33+00:00

everyone. I’m trying to make a basic tycoon game for Android and I’m trying

  • 0

everyone.
I’m trying to make a basic tycoon game for Android
and I’m trying to increment the value of text-views every 5 seconds with a timer,
But the textview doesn’t update.
Here’s my code so far:

public class Town extends Activity implements OnClickListener {
Timer timer;
TimerTask task;
TextView goldTV;
TextView woodTV;
TextView foodTV;
TextView stoneTV;
TextView cashTV;
int gold = 20;
int wood = 20;
int food = 20;
int stone = 20;
int cash = 200;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_town);
    goldTV = (TextView) findViewById(R.id.textView1);
    woodTV = (TextView) findViewById(R.id.TextView01);
    foodTV = (TextView) findViewById(R.id.TextView02);
    stoneTV = (TextView) findViewById(R.id.TextView03);
    cashTV = (TextView) findViewById(R.id.TextView04);
    timer = new Timer();
    task = new TimerTask() {

        @Override
        public void run() {
            gold++;
            goldTV.setText(gold);
            try {
                this.wait(2000);
            }
            catch (InterruptedException e){
            }
        }

    };
}
@Override
public void onClick(View arg0) {
    // TODO Auto-generated method stub

}

}

  • 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-15T01:43:34+00:00Added an answer on June 15, 2026 at 1:43 am

    a TimerTask should be used with a Timer object. in your code you never run the task.

    edit:
    try this instead:

    goldTV.postDelayed(new Runnable() {
    
                @Override
                public void run() {
                    gold++;
                    goldTV.setText(gold+"");
                    goldTV.postDelayed(this,2000);
                }
            }, 2000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone. I'm trying to save a picture with android to the public pictures directory
everyone. This is a piece of code from using sqlite in android tutorial: return
Everyone, every blog is talking about HTML 5 and giving solution to use HTML
everyone! I try to update values in .resx file with ResXResourceWriter and the value
everyone! I'm confusing with implementing a piece of code to make work .net data
everyone, I made a shooting game just like 1942(classic shooting game),but here's the question,
Everyone knows the advantages of a more readable code. So in order to make
Everyone, I am a newbie to android development. Now I have a question that
everyone. I am an experienced C programmer trying to get adjusted to C++. I
everyone, my question is very simple: I'm using Android emulator. I try to create

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.