xUs*_*ser 6 android android-databinding
我遇到了不同布局的数据绑定问题。我有不同方向的布局文件。对于纵向模式:
<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>
Run Code Online (Sandbox Code Playgroud)
对于陆地模式:
<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>
Run Code Online (Sandbox Code Playgroud)
当我使用它进行绑定时
ViewBinding binding = DataBindingUtil.setContentView(this, R.layout.view);
Run Code Online (Sandbox Code Playgroud)
我无法extraContainer从当前绑定访问。
添加具有相同 ID 的视图并在运行时检查视图类的可能解决方案。任何其他解决方案?
| 归档时间: |
|
| 查看次数: |
1580 次 |
| 最近记录: |