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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:04:38+00:00 2026-06-02T04:04:38+00:00

I have several Views, text views, and a button that have the android:visibility=invisible attribute.

  • 0

I have several Views, text views, and a button that have the android:visibility=”invisible” attribute. My goal is to click a button that resides above these ‘invisible’ widgets, so that these widgets will become visible. I created another java class called ‘VisibilityActivity.java” and tried the following method. But for some reason when I run the app, the button doesn’t do anything. I don’t know what I’m missing.

Here’s the code:

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class VisibilityActivity extends Activity {

    private View mVictim;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_property3);

        mVictim = findViewById(R.id.horizontalRule1);
        mVictim = findViewById(R.id.TextView03);
        mVictim = findViewById(R.id.horizontalRule2);

        Button submitRating = (Button) findViewById(R.id.submitRatingButton);

        submitRating.setOnClickListener(mVisibleListener);

    }

    OnClickListener mVisibleListener = new OnClickListener() {
        public void onClick(View v) {
            mVictim.setVisibility(View.INVISIBLE);
        }
    };

}

Here is the xml:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/custom_background"
android:isScrollContainer="true"
android:orientation="vertical"
android:paddingTop="10dp" >

    <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_gravity="center"
    android:text="@string/ratingsInfo"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/black1" />

    <View 
    android:layout_width="fill_parent" 
    android:layout_height="2dp"
    android:background="@color/black1"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:layout_marginBottom="5dp" />

    <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:text="@string/yourRating"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/black1" />

    <RatingBar
    android:id="@+id/ratingBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="10dp" />

    <Button
    android:id="@+id/submitRatingButton"
    android:layout_width="275dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="10dp"
    android:background="@drawable/custom_button"
    android:text="@string/submitRating"
    android:textColor="@color/black1" />


    <View 
    android:id="@+id/horizontalRule1"
    android:layout_width="fill_parent" 
    android:layout_height="2dp"
    android:background="@color/black1"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:layout_marginBottom="5dp"
    android:visibility="invisible" />

    <TextView
    android:id="@+id/TextView03"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:layout_gravity="center"
    android:text="@string/summaryInfo"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/black1"
    android:visibility="invisible" />

    <View 
    android:id="@+id/horizontalRule2"
    android:layout_width="fill_parent" 
    android:layout_height="2dp"
    android:background="@color/black1"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    android:layout_marginBottom="5dp"
    android:visibility="invisible" />

    <TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:text="@string/ourRating"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/black1"
    android:visibility="invisible" />

    <RatingBar
    android:id="@+id/ratingBar2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:stepSize=".01"
    android:layout_marginBottom="10dp"
    android:visibility="invisible" />

    <TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="5dp"
    android:text="@string/overallRating"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/black1"
    android:visibility="invisible" />

    <RatingBar
    android:id="@+id/ratingBar3"
    android:color="@color/black1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:stepSize=".01"
    android:layout_marginBottom="40dp"
    android:visibility="invisible" />

    <Button
    android:id="@+id/saveContinueButton3"
    android:layout_width="275dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="15dp"
    android:background="@drawable/custom_button"
    android:text="@string/saveContinue"
    android:textColor="@color/black1"
    android:onClick="onSaveAndContinue3Clicked"
    android:visibility="invisible" />

</LinearLayout>
</ScrollView>

Thanks. Help would be greatly appreciated!

  • 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-02T04:04:40+00:00Added an answer on June 2, 2026 at 4:04 am

    I am updating user936414‘s answer.

    OnClickListener mVisibleListener = new OnClickListener() {
        public void onClick(View v) {
    
            if( mText.getVisibility() == View.INVISIBLE )
                mText.setVisibility(View.VISIBLE);
            else
                mText.setVisibility(View.INVISIBLE);
    
            if( mRule1.getVisibility() == View.INVISIBLE )
                mRule1.setVisibility(View.VISIBLE);
            else
                mRule1.setVisibility(View.INVISIBLE);
    
            if( mRule2.getVisibility() == View.INVISIBLE )
                mRule2.setVisibility(View.VISIBLE);
            else
                mRule2.setVisibility(View.INVISIBLE);
        }
    };
    

    Also you might want to experiment with View.GONE.

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

Sidebar

Related Questions

I have an app that have several views. In one view I would like
I have an application with several windows/views that show the same object. For example
I have a window that contains several rather complex views. Right now, I'm using
I have several UILabels of various sizes on my Views. I want all the
i have user control, which i render on several views. i want to show
If you have several view models on one page, how do you ensure that
I have a view that can take several seconds to process a GET request
I have an element that needs to behave like UIButton but it has several
How to create a shelf like view in android that show several book in
I have an application with several (8) different Views in a UIScrollView. They are

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.