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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:08:00+00:00 2026-06-10T21:08:00+00:00

I have a TextView that displays a number (in this case, the number is

  • 0

I have a TextView that displays a number (in this case, the number is 10).

Now, i have a button so the user has to press that button 10 times in order for the number to hit 0, resulting in moving on to the next level. However,

I can keep hitting that button and it starts its way back into the negatives (-1, -2, etc.).

I tried to think of how I would prevent this but I’m at loss.. any ideas?

———————————–EDIT—————————————–

Okay, so here is my update (I got it to stop at 0):

public void onClick(View v) {
        // TODO Auto-generated method stub

        if (scr >= 1) {

            scr = scr - 1;
           TextView Score = (TextView) findViewById(R.id.Score);
           Score.setText(String.valueOf(scr));
        }

        if (scr == 10) 
        {
               aCounter.start();
        }

        if (scr == 1) 
        {
            aCounter.cancel();
            new AlertDialog.Builder(Tap_Game_Activity.this)
             .setTitle("Congratulations!").setMessage("Go to Level 2?")
             .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface AlertDialog, int PositiveButton) {
                  setContentView(R.layout.activity_level02_activity);
              }
               })
             .setNegativeButton("No", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface AlertDialog, int NegativeButton) {
                   }
                   }).show();
        }

    }});
}

(EDIT!): I fixed the AlertDialog by changing the 2 ‘Else If’ statements to just ‘If’ statements. However, my timer still doesn’t work :(, any help?

  • 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-10T21:08:01+00:00Added an answer on June 10, 2026 at 9:08 pm

    suppose number is the variable you are showing in the TextView, consider following code,

    int number = 10; 
    
    if ( number > 0 ) 
    {
        yourTextView.setText ( String.valueOf ( number ) ); 
    }
    else
    {
        // do not set text
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a TextView that displays an number like 0 and you
I have a Linear Layout that has a Button and a TextView on it.
I have a TextView that displays an error message in the login page of
I am having an issue with my TextView. I have a PlayScreenActivity that displays
I have a custom listview row that contains a number of textView components. Instead
I have a custom Dialog that contains only a TextView to display some text
Guess that I have a TextView that I want to update it in some
I want to have a TextView on the left that fills space, plus a
I have an XML layout that defines a TextView box 50px x 320px who
I have an activity that shows some TextView s and EditText s, as well

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.