Skip to content

Instantly share code, notes, and snippets.

@Augusent
Last active May 17, 2017 18:26
Show Gist options
  • Save Augusent/56c890debdc8f580f4b536385e1760f8 to your computer and use it in GitHub Desktop.
Save Augusent/56c890debdc8f580f4b536385e1760f8 to your computer and use it in GitHub Desktop.
XML (DataBinding) Example
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<import type="nda.AgePeriod"/>
<import type="nda.screen.gamecreate.EditableGameViewModel"/>
<variable
name="model"
type="nda.gameproperties.GamePropertiesViewModel"/>
<variable
name="selectedSports"
type="java.util.List&lt;Long&gt;"/>
<variable
name="maxPlayers"
type="int"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
bind:visible="@{model.gameDetailsVisible}">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/small"
android:text="@string/number_of_players_label"
android:textAppearance="@style/TextAppearance.Subhead"/>
<com.mdmtrade.gosportnow.screen.base.widget.NumberPickerView
style="@style/InputStyle.SingleLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal"
android:enabled="@{model.selectedSports.size() > 0}"
android:hint="@string/hint_number_of_players"
app:np_max="@={model.maxPlayers}"
app:np_min="@={model.minPlayers}"
app:np_title="@string/number_of_players"
app:np_value="@={model.numberOfPlayers}"/>
<include layout="@layout/divider_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/small"
android:text="@{model.agePeriodLabel}"
android:textAppearance="@style/TextAppearance.Subhead"/>
<AutoCompleteTextView
android:id="@+id/age_periods_edit"
style="@style/InputStyle.SingleLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal"
android:focusable="false"
android:hint="@string/choose_age_period"
android:text="@{model.agePeriod.displayName}"
bind:adapterItems="@{model.agePeriods}"/>
<include layout="@layout/divider_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/small"
android:text="@string/total_facility_fee"
android:textAppearance="@style/TextAppearance.Subhead"/>
<EditText
style="@style/InputStyle.SingleLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal"
android:hint="@string/hint_total_facility_fee"
android:inputType="numberDecimal"
android:text="@={model.totalFacility}"/>
<include layout="@layout/divider_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/small"
android:text="@string/additional_details_label"
android:textAppearance="@style/TextAppearance.Subhead"/>
<EditText
style="@style/InputStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal"
android:gravity="top"
android:hint="@string/hint_additional_details"
android:maxLength="160"
android:minLines="3"
android:text="@={model.additionalDetails}"/>
<include layout="@layout/divider_horizontal"/>
</LinearLayout>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment