更改AdView位置时出现ClassCastException

Mea*_*tje 2 java android android-layout

我正试图改变我AdView在SherlockFragmentActivity中的位置(带标签).由于它现在AdView显示在屏幕的底部,我想改变它的位置,AdView因此它显示在ActionBar选项卡和片段布局之间.

这是我的布局,屏幕底部有广告(这很好用):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </FrameLayout>

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/adview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="@string/admod_id" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我试图改变它的方式:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/adview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="@string/admod_id" />

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >
    </FrameLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

此更改会导致方法ClassCastExeption中的以下代码行onCreate().

        adView = (AdView) findViewById(R.id.adview);
Run Code Online (Sandbox Code Playgroud)

有这个错误消息:

        Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.ads.AdView
Run Code Online (Sandbox Code Playgroud)

如果有人能够解释为什么会导致这种情况ClassCastException以及如何解决这个问题,那将会很棒.

And*_*Res 11

更改位置后尝试清理项目.