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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:09:29+00:00 2026-05-29T09:09:29+00:00

I’m creating a toolbar that toggles the visibility of buttons when you click a

  • 0

I’m creating a toolbar that toggles the visibility of buttons when you click a button from a toolbar. So, if the user clicks on the “Draw” button, invisible buttons “Pencil” and Pen” will become visible above the “Draw” button. If you click the “Draw” button again, the buttons “Pencil” and “Pen” will become invisible again.

Within my xml file I have set the visibilty of some buttons to be “invisible” so when I launch the activity they won’t be seen. This part is straight forward.

.xml file of btnDrawLine – (Update @ 12:21)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" >

<com.odhranlynch.testSection.UserInterface
    android:id="@+id/UserInterface"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true" />

<Button
    android:id="@+id/btnDraw"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="Draw" />

<Button
    android:id="@+id/btnDrawLine"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btnDraw"
    android:layout_alignParentLeft="true"
    android:visibility="visible"
    android:text="Line" />

<Button
    android:id="@+id/btnDrawCurve"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btnDrawLine"
    android:layout_alignParentLeft="true"
    android:visibility="visible"
    android:text="Curve" />

<Button
    android:id="@+id/btnCutout"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_toRightOf="@+id/btnDraw"
    android:text="Cutout" />

<Button
    android:id="@+id/btnCutInner"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_above="@+id/btnDraw"
    android:layout_toRightOf="@+id/btnDraw"
    android:visibility="visible"
    android:text="Inner" />

<Button
    android:id="@+id/btnCutOutter"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/btnDrawCurve"
    android:layout_alignBottom="@+id/btnDrawCurve"
    android:layout_toLeftOf="@+id/btnCancel"
    android:visibility="visible"
    android:text="Outter" />

<Button
    android:id="@+id/btnCancel"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_toLeftOf="@+id/btnFinish"
    android:text="Cancel" />

<Button
    android:id="@+id/btnFinish"
    android:layout_width="80dip"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:text="Finish" />

</RelativeLayout>

Next, when the user clicks a button that is visible, I’d like the invisible buttons to appear.

Here’s the thing, they won’t reappear!lol I’m confused by it.

I would be very grateful if someone would be kind enough to shed so light onto this for me 🙂

testActivity.java

package com.odhranlynch.testSection;

import com.odhranlynch.testSection.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class testActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.new_product);

    // Find buttons and give them a name.
    final View btnDraw = findViewById(R.id.btnDraw);
    final View btnCutOut = findViewById(R.id.btnCutout);
    final View btnDrawLine = findViewById(R.id.btnDrawLine);
    final View btnDrawCurve = findViewById(R.id.btnDrawCurve);
    final View btnCutInner = findViewById(R.id.btnCutInner);
    final View btnCutOutter = findViewById(R.id.btnCutOutter);


    //Draw Button clicked (UI Toolbar).
    btnDraw.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            //Treat button as a toggle button
            //So if a sub-button (e.g. Draw Line) is visible, then we know the button has
            //been toggled to visible so lets now make it invisible.

            if (btnDrawLine.getVisibility()== View.VISIBLE) {
                //Its visible.
                btnDrawLine.setVisibility(View.INVISIBLE);

                btnDrawCurve.setVisibility(View.INVISIBLE);
                Log.d("TAG", "INVISIBLE");
            } else {
                // Either gone or invisible
                btnDrawLine.setVisibility(View.VISIBLE);
                btnDrawCurve.setVisibility(View.VISIBLE);
                Log.d("TAG", "VISIBLE");
            }
        }
    });     

}
}

As a further point to mention, if I set the visibilty of the buttons to be visible within the .xml file I can toggle the visibilty perfectly fine during runtime!

Again, I would be grateful of some 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-05-29T09:09:30+00:00Added an answer on May 29, 2026 at 9:09 am

    Try replacing View.INVISIBLE to View.GONE.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this

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.