正如你可以与你的代码中动态改变的片段,机器人工作室不知道在设计时要显示的布局。这是你错误的原因。 要具体告诉android显示哪个布局,请将tools:layout="@layout/Your_layout_name"
属性添加到您的片段。 错误描述下面还有一个快捷方式链接,您已经知道。只需点击链接,android会为你添加它,你会看到布局中的片段,没有渲染错误信息。 有关详细示例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.insane.fragmenttest.MainActivity">
<fragment
android:id="@+id/testFragmentID"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.insane.fragmenttest.WorkOutDetails"
tools:layout="@layout/fragment_work_out_details" /> <!-- This is the line you want to add. -->
</LinearLayout>