2 düzenim var: biri v19 + için ve diğeri daha eski sürümler için. Farklı kimliklerle farklı görünümler içerirler. Her iki düzende de çalışmak istediğim Android DataBinding framework'ü nasıl söyleyebilirim? Sadece bir düzen için görünümler oluşturur (rasgele seçer).Çeşitli niteleyicilerle düzen nasıl bağlanır
düzen/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>
düzen-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>
Güncelleme:
Sonunda sorunun kök öğrendim. Neden bilmiyorum ama * BindingImpl dosyaları kullanmazken minSdkVersion 21 kullanılır. Daha önceki sürümleri belirtiyorsa, bu şu şekilde çalışır: @yigit
Ayrıca referans için [this] (http://chintanrathod.com/develop_apps_faster_using_data_binding_part2/) eğitimini de kontrol edebilirsiniz. –
Sorun ayrıntılarını kapsamaz – LackOfKnowledge