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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:38:51+00:00 2026-06-17T23:38:51+00:00

I have a menu imageview, when clicked on it my linearlayout(line2) appears, but it

  • 0

I have a menu imageview, when clicked on it my linearlayout(line2) appears, but it should again disappear on the next click of menu imageview

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
line1=(LinearLayout) findViewById(R.id.ll1);
         line2=(LinearLayout)findViewById(R.id.ll2);

         menu=(ImageView)findViewById(R.id.menu);

         menu.setOnClickListener(new OnClickListener() {

       public void onClick(View v) {
           menu.setVisibility(View.VISIBLE);
         // TODO Auto-generated method stub
       line1.setVisibility(View.VISIBLE);
       line2.setVisibility(View.VISIBLE);
         }
     });
  • 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-17T23:38:52+00:00Added an answer on June 17, 2026 at 11:38 pm

    You can use an if/else statement to check the current state every time your button is pressed and switch. You don’t necessarily need to check for the visibility being GONE if you’re not going to set it to GONE ever so you can remove that condition.

    The difference between GONE and INVISIBLE is that the layout reacts to gone as if it weren’t even there, the element no longer causes any displacement.

    Change line2.setVisibility(View.VISIBLE); to

       if (line2.getVisibility() == View.GONE || line2.getVisibility() == View.INVISIBLE ) {
           line2.setVisibility(View.VISIBLE); } 
       else { 
           line2.setVisibility(View.GONE); // Set it to View.INVISIBLE if thats your goal.
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Menu imageview in all the pages of my app, if clicked
I have this menu structure: http://jsfiddle.net/Rochefort/szL2C/ everything is ok. But i want, hover effect
So, I have an imageview that should display an arbitrary image, a profile picture
I have a Menu button image and onclick of that ImageView i have to
In my app i have a popup menu, when i click the menuitem it
I have 1 activity, but would like to have multiple context menu's for different
In one Android activity I have added a context menu to an ImageView with
I have menu structure as show here . All item have a background img.
I have menu bar and code is as follows <div style=background:#000; height: 25px;> <div
I have developed a ios game with 20 levels. I have menu at starting

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.