1<!-- 2 Copyright (C) 2014 The Android Open Source Project 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 --> 16 17<layout xmlns:android="http://schemas.android.com/apk/res/android" 18 xmlns:bind="http://schemas.android.com/apk/res-auto" 19 xmlns:tools="http://schemas.android.com/tools"> 20 <data> 21 <variable name="activity" type="com.android.example.bindingdemo.MainActivity"/> 22 <!----> 23 <import 24 type="android.view.View" 25 /> 26 <!----> 27 <import type="com.android.example.bindingdemo.R.string" alias="Strings"/> 28 <import type="com.android.example.bindingdemo.vo.User"/> 29 </data> 30 <LinearLayout 31 android:layout_width="match_parent" 32 android:layout_height="match_parent" 33 android:orientation="vertical" 34 android:paddingBottom="@dimen/activity_vertical_margin" 35 android:paddingLeft="@dimen/activity_horizontal_margin" 36 android:paddingRight="@dimen/activity_horizontal_margin" 37 android:paddingTop="@dimen/activity_vertical_margin" 38 android:id="@+id/activityRoot" 39 tools:activity=".MainActivity" 40 android:clickable="true" 41 android:onClickListener="@{activity.onUnselect}"> 42 <TextView 43 android:id="@+id/title" 44 android:layout_width="wrap_content" 45 android:layout_height="wrap_content" 46 android:text="@{@plurals/kittens(activity.tkAdapter.itemCount, activity.tkAdapter.itemCount)}"> 47 48 </TextView> 49 50 <android.support.v7.widget.RecyclerView 51 android:id="@+id/toolkittyList" 52 android:layout_width="match_parent" 53 android:layout_height="@dimen/list_height" 54 bind:adapter="@{activity.tkAdapter}" 55 ></android.support.v7.widget.RecyclerView> 56 57 <View 58 android:layout_width="match_parent" 59 android:layout_height="10dp" /> 60 61 <android.support.v7.widget.CardView 62 android:id="@+id/selected_card" 63 bind:contentPadding="@{activity.selected == null ? 5 : activity.selected.name.length()}" 64 android:layout_width="match_parent" 65 android:layout_height="wrap_content" 66 bind:visibility="@{activity.selected == null ? View.INVISIBLE : View.VISIBLE}"> 67 68 <GridLayout 69 android:layout_width="match_parent" 70 android:layout_height="wrap_content" 71 android:columnCount="2" 72 android:rowCount="4"> 73 74 <ImageView 75 android:id="@+id/selected_photo" 76 android:layout_width="@dimen/big_user_photo" 77 android:layout_height="@dimen/big_user_photo" 78 android:layout_column="0" 79 android:layout_row="0" 80 android:layout_rowSpan="2" 81 android:scaleType="fitCenter" 82 android:backgroundResource="@{activity.selected.photoResource}" /> 83 84 <EditText 85 android:id="@+id/selected_name" 86 android:layout_width="wrap_content" 87 android:layout_height="wrap_content" 88 android:layout_column="1" 89 android:layout_gravity="fill" 90 android:layout_row="0" 91 android:background="@android:color/holo_blue_dark" 92 android:gravity="center" 93 android:text="@{activity.selected.name}" /> 94 95 <EditText 96 android:id="@+id/selected_lastname" 97 android:layout_width="wrap_content" 98 android:layout_height="wrap_content" 99 android:layout_column="1" 100 android:layout_gravity="fill" 101 android:layout_row="1" 102 android:background="@android:color/holo_blue_bright" 103 android:gravity="center" 104 android:text="@{activity.selected.lastName}" /> 105 <Button 106 android:id="@+id/edit_button" 107 bind:onClickListener="@{activity.onSave}" 108 android:text='@{"Save changes to " + activity.selected.name}' 109 android:layout_width="wrap_content" 110 android:layout_height="wrap_content" 111 android:layout_column="1" 112 android:layout_gravity="right" 113 android:layout_row="2"/> 114 115 <Button 116 android:id="@+id/delete_button" 117 bind:onClickListener="@{activity.onDelete}" 118 android:text="@{activity.getString(activity.selected.group == User.KITTEN ? Strings.became_robot : Strings.became_kitten, activity.selected.name)}" 119 android:layout_width="wrap_content" 120 android:layout_height="wrap_content" 121 android:layout_column="1" 122 android:layout_gravity="right" 123 android:layout_row="3"/> 124 125 </GridLayout> 126 </android.support.v7.widget.CardView> 127 <View 128 android:layout_width="match_parent" 129 android:layout_height="10dp" /> 130 <TextView 131 android:layout_width="wrap_content" 132 android:layout_height="wrap_content" 133 android:text='@{activity.robotAdapter.itemCount + " Robots "}' /> 134 <android.support.v7.widget.RecyclerView 135 android:id="@+id/robotList" 136 android:layout_width="match_parent" bind:adapter="@{activity.robotAdapter}" android:layout_height="@dimen/list_height" 137 ></android.support.v7.widget.RecyclerView> 138 </LinearLayout> 139</layout>