vendredi 30 septembre 2016

android checkbox show and hide

I have a checkbox in linearlayout6 when i click on the checkbox i want to show linearlayout7,linearlayout8,linearlayout9. otherwise i want to hide these 3 linearlayout(7,8,9).

checkbox

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkbox1"
/>

XML

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:text="@string/string41" />

    <EditText
        android:id="@+id/txtTitle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:ems="10"
        android:hint="@string/string41"/>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout2">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:text="@string/string42" />

    <EditText
        android:id="@+id/txtAuthor"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:ems="10"
        android:hint="@string/string42"/>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout3">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.25"
        android:text="@string/string43" />

    <EditText
        android:id="@+id/txtPublisher"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:ems="10"
        android:hint="@string/string43"/>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout4">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.25"
        android:text="@string/string44" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/txtIsbn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:hint="@string/string44"/>
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout5">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.25"
        android:text="@string/string45" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:hint="@string/string45" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout6">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkbox1"
/>
    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="0.25"
            android:text="@string/string46" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout7">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.25"
        android:text="@string/string47" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:hint="@string/string47" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout8">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.25"
        android:text="@string/string48" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:hint="@string/string48" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:id="@+id/screen4layout9">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_weight="0.25"
        android:text="@string/string49" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/editText9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:hint="@string/string49" />
    </LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="81dp"
    android:orientation="horizontal"
    android:id="@+id/screen4layout10">

    <View
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.25" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.75"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btnSubmit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:text="@string/save" />

        <Button
            android:id="@+id/btnCancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="5"
            android:text="Delete" />
        <Button
            android:id="@+id/btn_close_popup4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Close" />
    </LinearLayout>
</LinearLayout>




Aucun commentaire:

Enregistrer un commentaire