私は、異なるレイアウトのデータバインディングに関する問題に直面しました。 私はさまざまな向きのレイアウトファイルを持っています。ポートレートモードの場合 : 代替レイアウトのデータバインド
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</layout>
とlandspaceモードの
:<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/extra_container"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="match_parent" />
</LinearLayout>
</layout>
を私は
ViewBinding binding = DataBindingUtil.setContentView(this, R.layout.view);
を経由して結合するためにそれを使用するとき、私は現在のバインディングからextraContainer
のためアクセスできません。
同じIDを持つビューを追加し、実行時にビュークラスをチェックする可能性のある解決策。その他のソリューション?
レイアウト構造を教えていただけますか? –
'res/layout/view.xml'と' res/layout-sw600dp-land/view.xml' – xUser
私はこれについて何かエラーを見ることはできません。これがなぜ機能していないのか分かりません。 –