Android xml中标签使用id的坑
例1
<View>
<include layout="@layout/page"/>
</View>
include标签没有id时,可以直接通过rootVIew的findViewById来直接寻找page里面的view,如
Button button = rootView.findViewById(R.id.button);
例2
<View>
<include
layout="@layout/page"
id="@+id/layout"/>
</View>
include标签有id时,必须通过layout这个view的findViewById方法来寻找他的子View,如
View view = rootView.findViewById(R.id.page);
Button button = view.findViewById(R.id.button);