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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:12:29+00:00 2026-06-01T11:12:29+00:00

I have a button that basically looks like this: <Button android:id=@+id/admin_new_questions android:layout_width=fill_parent android:layout_height=wrap_content android:text=See

  • 0

I have a button that basically looks like this:

 <Button
    android:id="@+id/admin_new_questions"        
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="See Asked Questions"
    />    

and I try to display it only in some cases like this:

if ( clause )
{
        Button admin_see_questions = (Button)findViewById(R.id.admin_new_questions);   
        admin_see_questions.setOnClickListener(new Button.OnClickListener() 
        {  
            public void onClick(View v) 
            {
           ....    
            }
        });        
}

But for some reason, the button is displayed for all cases, but the listenter is not being listened to if the clause is an error.

How can I make the button show up only when the clause is true?

Thanks!

  • 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-01T11:12:31+00:00Added an answer on June 1, 2026 at 11:12 am

    Your button is in the XML layout, so you can hide it or show it by just changing its visibility

    NB: You only need do these operations once:

    1. Get a reference to your button, with findViewById()
    2. Set the OnClickListener of the button

      <Button
      android:id="@+id/admin_new_questions"        
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="See Asked Questions"
      
      android:visibility="invisible" //Initially hide the button
      
      />    
      

    –

    Button admin_see_questions = (Button)findViewById(R.id.admin_new_questions);   
    admin_see_questions.setOnClickListener(new Button.OnClickListener() 
    {  
        public void onClick(View v) 
        {
            ....       
        }
    });  
    
    if ( clause )
    {
        admin_see_questions.setVisibility(View.VISIBLE); //SHOW the button
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have run-time loaded class that looks like this: [Plugin(Plugin name)] class PluginActions
I have a table that looks like this: <table name=exercises id=workout-table> <tr> <th>Name</th> <th>Reps/Intervals</th>
I have a layout that looks kind of like this: And the code looks
I am using MVVM Light. I have created a window that looks like this:
I have a button that I would like to disable when the form submits
We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my
I have a button that I'm creating in a UIViewController like so: TOLoginButton* button
I am attempting to create a Tab Control Style that basically looks like buttons
I have some simple javascript that I'd like to run when a button is
I have following components - ColorButton, that represents single button that is basically colored

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.