如何在代码中删除frameLayout?

时间:2012-07-06 02:43:01

标签: android android-layout

我想从屏幕上删除包含textview的framelayout,以便所有其他布局向上移动并取而代之。这是布局:

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >


            <EditText
                android:id="@+id/etWarning"
                android:layout_width="fill_parent"
                android:layout_height="109dp"
                android:clickable="false"
                android:ems="10"
                android:enabled="false"
                android:focusable="false"
                android:inputType="textMultiLine" />

        </FrameLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp" >

            <TextView
                android:id="@+id/tvReasonLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/ndr_Reason"
                android:textAppearance="?android:attr/textAppearanceMedium" />


            <Spinner
                android:id="@+id/spinNDRreasons"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

               <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/tvQueston"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="10dp"
                android:paddingBottom="5dp"
                android:text="Extra question goes here"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">


            <EditText
                android:id="@+id/etResponse"
                android:layout_width="wrap_content"
                android:layout_height="120dp"
                android:layout_weight="1"
                android:ems="10"
                android:inputType="textMultiLine" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <Button
                android:id="@+id/cmdDoneNDR"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/cmd_done" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

顶部布局是我希望能够添加/删除的布局,如果它不在那里,其他布局会向上移动。

我是否需要一个framelayout?

感谢

1 个答案:

答案 0 :(得分:3)

给framelayout一个id,并在你的java活动代码中,将该视图的setvisibility设置为消失。

实际上,因为你在framelayout中只有一个视图,你可能只想做

etWarning.setVisibility(View.GONE); // this is for gone

etWarning.setVisibility(View.VISBLE); // this is to show it

希望这会有所帮助

相关问题