0

我有 2 个 xml 文件,在第一个文件中需要导入第二个文件,我尝试使用Xinclude来做到这一点:

第一个.xml:

<FirstXml name="first" xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="second.xml"/>
</FirstXml>

第二个.xml

<SecondXml name="second>
  ...
</SecondXml>

然后我尝试创建 DocumentBuilderFactory 的实例并启用 XInclude 处理。

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setXIncludeAware(true);

但是当我尝试启用 XInclude 处理时会抛出 UnsupportedOperationException。

该文档说,当使用早期版本的 JAXP 的实现时会引发此异常。

我该如何解决这个问题?或者我如何在android中进行这样的导入?

4

2 回答 2

1
 <include
    layout="@layout/app_bar_starting"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 

您可以尝试这些来导入第二个布局。

于 2017-03-15T07:31:43.470 回答
0

只需在您的 first.xml 文件中写入以下行

<include layout="@layout/custom_layout" />
于 2017-03-15T07:29:29.650 回答