私は2つのレイアウトを持っています.1つはv19 +用、もう1つは以前のバージョンです。それらは異なるIDを持つ異なるビューを含んでいます。どのように私は両方のレイアウトで動作するようにAndroidのデータバインディングフレームワークを言うことができますか? 1つのレイアウト(ランダムに選択)のビューのみを生成します。いくつかの修飾子を使ってレイアウトをバインドする方法
レイアウト/ temp_view.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="block"
type="ru.temp.model.content.blocks.WebMediaBlock" />
<import type="ru.temp.model.Types.ProviderTypes" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@android:color/white">
<ImageView
android:id="@+id/provider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="@dimen/size5"
android:src="@{ProviderTypes.fromString(block.provider).getResId()}" />
</FrameLayout>
</layout>
レイアウト-V19/temp_view.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="block"
type="ru.temp.model.content.blocks.WebMediaBlock" />
<import type="ru.temp.model.Types.ProviderTypes" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@android:color/white">
<ru.temp.utils.EmbedView
android:id="@+id/media_embed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ru.temp.structure.static_material.CreditsView
android:id="@+id/credits_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
</layout>
を更新:
最後に、私は、問題の根本を発見しました。理由は分かりませんが、minSdkVersionを使用するとBindingImplファイルが生成されません。21.以前のバージョンを指定すると、@yigitと同じように動作します。
参考までに[こちら](http://chintanrathod.com/develop_apps_faster_using_data_binding_part2/)チュートリアルをチェックすることもできます。 –
問題の詳細をカバーしていません – LackOfKnowledge