Java admob的xml呈现问题

Java admob的xml呈现问题,java,android,Java,Android,我正在学习本教程,了解如何在应用程序上获取adMob,以及 在活动的xml布局文件中,我遇到了一个渲染问题: A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout yo

我正在学习本教程,了解如何在应用程序上获取adMob,以及 在活动的xml布局文件中,我遇到了一个渲染问题:

A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
- <fragment xetron.cosmicclicker.MyActivity$AdFragment ...> (Pick Layout...)
 Do not warn about <fragment> tags in this session 
标记允许布局文件在运行时动态包含不同的布局。在版面编辑时,不知道要使用的特定版面。您可以选择编辑布局时要预览的布局。
-(拾取布局…)
-(拾取布局…)
不警告此会话中的标记
下面活动的Xml布局文件

    <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"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="8dp"
    android:orientation="vertical"
    android:paddingBottom="6dp"
    android:gravity="center|top"
    android:background="@drawable/background"
    tools:context=".MyActivity">



    <fragment
        android:name="xetron.cosmicclicker.MyActivity$AdFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/adFragment" />

    <fragment
        android:id="@+id/adFragment"
        android:name="xetron.cosmicclicker.MyActivity$AdFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" />



</LinearLayout>


我做错了什么?我该如何解决这个问题?

在您的片段中,尝试放置以下内容:

工具:layout=“@layout/my\u fragment\u view”

其中,my_fragment_视图是要加载到片段中的布局。这仅适用于观众。我认为图形视图为您提供了一个提示,使其能够更平滑地渲染。“工具”属性仅适用于编辑器。在运行时不工作

 <fragment
        android:name="xetron.cosmicclicker.MyActivity$AdFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout="@layout/my_fragment_view"
        android:layout_above="@+id/adFragment" />


您使用的是android studio吗?是的,我使用的是android studio。请有人帮助您创建片段视图。您希望片段显示什么布局?输入它,而不是我的片段视图。片段就像一个子活动,它通常包含一个布局文件。之后,如果你想真正加载布局,请添加:android:name=“xetron.cosmicclicker.which_myFragment_name_是什么”我把它改成了我的片段广告,我没有收到任何渲染错误,但我在我的活动中收到一个错误,上面写着setContentView(R.layout.activity_my);该应用程序刚刚崩溃,导致出现一行代码,上面写着SetContentView(R.layout.activity_my)您能显示此活动的上下文吗?它在布局文件夹中吗?