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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:42:14+00:00 2026-06-15T19:42:14+00:00

I currently have it set up so there are a couple TextViews: One of

  • 0

I currently have it set up so there are a couple TextViews:

  • One of them is updated when one button is clicked, the other button does not alter it when clicked.

  • The other TextViews display a number and I would like them to be altered when either one of the buttons is clicked, but currently all of the TextViews are visible and the numbers are not altered.

I would like the other TextViews (num1-num3 below) to be invisible initially, then when the user clicks either one of the buttons, the TextViews become visible and their values are updated by a method that I have written.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_name);
    num1 = randNum();
    num1 = alterNum(num1);      
    num1View = (TextView) findViewById(R.id.number1); 
    num1View.setText("Num1 Number: " + String.valueOf(num1));

    num2 = randNum();
    num2 = alterNum(num2);
    num2View = (TextView) findViewById(R.id.number2); 
    num2View.setText("Num2 Number: " + String.valueOf(num2));

    num3 = randNum();
    num3 = alterNum(num3);
    num3View = (TextView) findViewById(R.id.number3); 
    num3View.setText("Num3 Number: " + String.valueOf(num3));

    // This one is always visible, the ones above should be invisible
    // and appear onClick
    currentNum = randNum();
    myTextView = (TextView) findViewById(R.id.current_number); 
    myTextView.setText("Current Number: " + String.valueOf(currentNum));
    okButton = (Button) findViewById(R.id.ok_button);
    okButton.setOnClickListener(this);
    changeButton = (Button) findViewById(R.id.change_button);
    changeButton.setOnClickListener(this);
}

My onClick:

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.num_confirmation:
        //do nothing
        // do not let user hit buttons more than once (either case)
        changeButton.setEnabled(false);
        okButton.setEnabled(false);
        break;
    case R.id.swap_button:
        currentNum = alterNum();
        myTextView.setText("Current Number: " + String.valueOf(currentNum));
        // do not let user hit buttons more than once (either case)
        swapButton.setEnabled(false);
        okButton.setEnabled(false);
        break;
    default:
        break;
    }
}

How is this done?

  • 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-15T19:42:15+00:00Added an answer on June 15, 2026 at 7:42 pm

    set the initial value of “visible” to “invisible” in your xml layout file for textViews that should be invisible and in your onClick method alter its text valie and change visibility:

     myTextView.setVisibility(View.VISIBLE);
    

    here is similar question that should help: How to change visibility of layout programaticly

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

Sidebar

Related Questions

I currently have my code set to disable the submit button when the field
I have a couple of problems when doing blending in WebGL. One of them
I have recently set up a web server, which currently hosts a couple of
I currently have this set up and working fine inside a users folder. RewriteEngine
I currently have Magento set up on a development server (remote, SSH access) and
I currently have a set of tabs, each tied to a fragment, and I've
I currently have a .htaccess file set up with this rule: RewriteRule ^([a-zA-Z0-9_-]+)$ user\.php?user=$1
I am currently in C# and I have set Session variables on each page.
I currently have a MySQL dual master replication (A<->B) set up and everything seems
Currently I have a site that is set up using a masterpage and a

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.