<!--
  Copyright 2013 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<!--
    The ListView from sample_main.xml has a choiceMode set, meaning that when a user
    selects a list item, the ListView will set the state for that item's root view
    (this CheckableLinearLayout) to "checked". Note that this requires that the root view
    implements the Checkable interface. Once the root view is checked, any children that
    have the duplicateParentState attribute set will inherit this "checked" state.
-->
<com.example.android.customchoicelist.CheckableLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="8dp"
    android:paddingRight="8dp"
    android:minHeight="?android:listPreferredItemHeight"
    android:gravity="center_vertical">

    <!--
        The duplicateParentState attribute on this TextView, along with the color state list
        used in the textColor attribute causes its text color to change when its parent
        is checked or unchecked.
    -->
    <TextView android:id="@android:id/text1"
        android:duplicateParentState="true"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:textAppearance="?android:textAppearanceMedium"
        android:textColor="@color/hideable_text_color" />

    <!--
        The duplicateParentState attribute on this ImageView, along with the state list
        drawable in the src attribute causes its image to change when its parent
        is checked or unchecked.

        To use the standard radio or checkmark image, set the src to
        ?android:listChoiceIndicatorMultiple or ?android:listChoiceIndicatorSingle. These
        are system theme attributes that reference a state list drawable.
    -->
    <ImageView android:src="@drawable/ic_hideable_item"
        android:duplicateParentState="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp" />

</com.example.android.customchoicelist.CheckableLinearLayout>
