Java 更改AdView位置时的ClassCastException
我正在尝试更改我的Java 更改AdView位置时的ClassCastException,java,android,android-layout,Java,Android,Android Layout,我正在尝试更改我的AdView在SherlockFragmentActivity(带选项卡)中的位置。现在,屏幕底部显示了AdView,我想更改AdView的位置,使其显示在ActionBar选项卡和片段布局之间 这是我的布局,屏幕底部有广告(效果很好): 出现此错误消息时: Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.ads.Ad
AdView
在SherlockFragmentActivity(带选项卡)中的位置。现在,屏幕底部显示了AdView
,我想更改AdView
的位置,使其显示在ActionBar
选项卡和片段布局之间
这是我的布局,屏幕底部有广告(效果很好):
出现此错误消息时:
Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.ads.AdView
如果有人能解释为什么这会导致
ClassCastException
以及我将如何解决这个问题,那就太好了。在更改位置后尝试清理项目。Eclipse有时会弄乱res ID。尝试清理你的项目。
<?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>
adView = (AdView) findViewById(R.id.adview);
Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to com.google.ads.AdView