test.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include_content"
layout="@layout/content" />
</FrameLayout>
</layout>
content.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test button"/>
</FrameLayout>
</layout>
Java代码:
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
TestBinding binding=DataBindingUtil.setContentView(this, R.layout.test);
Button button = binding.includeContent.button;
}
当我运行应用程序时,Android Studio构建错误“找不到符号变量includeContent”
我想念什么?
检查这个答案。
基本上,如果您使用1.0-rc3或更低版本,则需要将一个值传递给包含的版式。
如果使用1.0-rc4或更高版本,则它应该在不传递值的情况下工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句