我在我的应用程序中使用 Navigation-Drawer。所以我使用 navigation_drawer 布局创建了单个活动。每当用户从导航抽屉菜单中选择菜单选项时,我都会使用片段来更改主要内容区域(@+id/content_frame)数据。现在我的问题是我想在每个屏幕上显示 admob 广告。我可以使用片段来初始化广告布局并将其膨胀到 FrameLayout 中,但我认为这不是一个好的选择。他们有什么方法可以使用该单一活动来初始化广告吗?
导航抽屉.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/side_navigation_background"
android:cacheColorHint="#00000000"
android:choiceMode="singleChoice"
android:divider="@color/side_navigation_list_divider_color"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>