Nested Linear layout only shows first view after being set from gone to visible in Android

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-06-10T21:20:34Z Indexed on 2010/06/10 21:22 UTC
Read the original article Hit count: 486

Filed under:
|
|

Hi guys,

I am developing an Android app but I'm still pretty new. I want to have a button, and when you push that button, a few TextViews and Buttons will appear. So I have a main linear layout, and then another linear layout nested inside containing the things I want hidden. I have the nested linear layout set to android:visibility="gone".

The problem I am having is that it only shows the first item inside the hidden linear layout instead of all of them. The way I try to make it appear is

    vgAddView = (ViewGroup)findViewById(R.id.add_details);

    btnAche.setOnClickListener(new OnClickListener(){
        public void onClick(View v){
            vgAddView.setVisibility(0);
        }
    });

My XML file is this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<Button 
    android:text="@string/but_stomach_ache" 
    android:id="@+id/but_stomach_ache" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
</Button>
<Button 
    android:text="@string/but_food" 
    android:id="@+id/but_food" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
</Button>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/add_details"
    android:visibility="gone">
    <TextView
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="@string/when_happen">
        </TextView>
    <Button 
        android:text="@string/happen_now" 
        android:id="@+id/happen_now" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content">
        </Button>
</LinearLayout>
</LinearLayout>

© Stack Overflow or respective owner

Related posts about android

Related posts about layout