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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:36:33+00:00 2026-05-30T04:36:33+00:00

I need this miss button to be GONE on the initial screen, then appear

  • 0

I need this miss button to be GONE on the initial screen, then appear when toggle button is toggled, and be GONE again when re-toggled.

The problem which persists atm is that the button isn’t gone initially on the initial screen, i have to press the toggle button twice, for it to be gone.

here’s the code:

toggle = (ToggleButton) findViewById(R.id.bRedGreen);
    toggle.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            pluskugle = (Button) findViewById(R.id.bBallhole);
            minuskugle = (Button) findViewById(R.id.bBallhole);

            pluskegle = (Button) findViewById(R.id.bKegle);
            minuskegle = (Button) findViewById(R.id.bKegle);

            plusmidkegle = (Button) findViewById(R.id.bKeglemid);
            minusmidkegle = (Button) findViewById(R.id.bKeglemid);

            bottomlayout = (LinearLayout) findViewById(R.id.bottomlayout);

            miss = (Button) findViewById(R.id.bMiss);

        if(toggle.isChecked())
        {
            minuskugle.setBackgroundResource(R.drawable.redballinhole);
            minuskegle.setBackgroundResource(R.drawable.redkegle);
            minusmidkegle.setBackgroundResource(R.drawable.midkegleminus);
            miss.setBackgroundResource(R.drawable.missbutton);

            miss.setVisibility(View.VISIBLE);

        }

        else 
        {
            pluskugle.setBackgroundResource(R.drawable.whiteballinhole);
            pluskegle.setBackgroundResource(R.drawable.kegleb);
            plusmidkegle.setBackgroundResource(R.drawable.midkegleplus);
            miss.setVisibility(View.GONE);

        }

        }

    });
}
  • 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-30T04:36:35+00:00Added an answer on May 30, 2026 at 4:36 am

    The behavior you’re seeing is the result of two things:

    -The reason the button is initially visible is that you don’t have android:visibility=”gone” in your XML, and the code to set it invisible hasn’t fired, because no click has occurred yet.

    -The reason you have to hit the toggle button twice to set it to invisible: The first click switches the toggle from not checked to checked, so the code sets the button (which is already visible) to visible. The SECOND click is the first time that an onClick fires and the toggle button isn’t checked. That’s when you actually see the button go invisible.

    To fix, just add “android:visibility=”GONE” as an attribute to the miss button in your layout XML.

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

Sidebar

Related Questions

I need this because the constructor in the superclass is calling a method which
I need this for some animation effects and i remember there is a window
I need this for calling a C function from Java class (JNI) and I
I need this roadmap of a Hibernate managed object instance. First, I create an
So from this string: name[id] I need this: id I used str.split ('[]'), but
All I need this for is strcpy(). I want to see whether the first
I don't need this declaration because it only makes my code big and unreadable.
[Revision 5/14/09: I need this to target Dotnet 2.0 because of my deployment scenario]
This is not homework, I need this for my program :) I ask this
I have no experience with low level programing and I need this piece of

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.