Android com.google.ads.AdView未能实例化错误
我尝试了很多事情,但都做不到。当我尝试时,应用程序总是崩溃。我希望广告在屏幕底部,而不是滚动到底部时覆盖最后一个listview项目 这是我的xml,它可以在没有广告的情况下工作。编辑:这是最新的代码。我发现com.google.ads.AdView未能实例化错误。我的广告在不同的版面中工作,但对于这个版面,它们不会显示Android com.google.ads.AdView未能实例化错误,android,xml,listview,layout,Android,Xml,Listview,Layout,我尝试了很多事情,但都做不到。当我尝试时,应用程序总是崩溃。我希望广告在屏幕底部,而不是滚动到底部时覆盖最后一个listview项目 这是我的xml,它可以在没有广告的情况下工作。编辑:这是最新的代码。我发现com.google.ads.AdView未能实例化错误。我的广告在不同的版面中工作,但对于这个版面,它们不会显示 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://sche
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adSize="BANNER"
ads:adUnitId="---------------------"
ads:loadAdOnCreate="true"
android:gravity="center_horizontal" />
</LinearLayout>
<FrameLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height">
<com.gains.myapp.KenBurnsView
android:id="@+id/header_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/picture0" />
<ImageView
android:id="@+id/header_logo"
android:layout_width="@dimen/header_logo_size"
android:layout_height="@dimen/header_logo_size"
android:layout_gravity="center"
android:src="@drawable/ic_header_logo" />
</FrameLayout>
将列表视图高度设置为覆盖屏幕四分之三的值。尝试400450 dp
为admob小部件设置property align parent bottom=true。这会将admob小部件粘到底部您已将ListView配置为使用其父级的所有高度,不留任何其他空间。我建议你尝试一些更像:
<Linearayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="1"/>
<FrameLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height">
<com.gains.myapp.KenBurnsView
android:id="@+id/header_picture"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/picture0" />
<ImageView
android:id="@+id/header_logo"
android:layout_width="@dimen/header_logo_size"
android:layout_height="@dimen/header_logo_size"
android:layout_gravity="center"
android:src="@drawable/ic_header_logo" />
</FrameLayout>
</LinearLayout>
请注意ListView配置中的android:layout_weight=“1”。这将导致ListView展开以填充其封闭线性布局中的可用空间
阅读
您需要更好地了解Android布局、何时使用以及它们如何工作。这就是我正在做的。列表视图在屏幕上覆盖的区域会发生变化。我是否将adview放在listview之后?首先是用户相对布局。然后按照我的步骤去做。我犯了一个可笑的错误。我今天读到的最有趣的事。此LinearLayout视图没有用处(没有子元素、没有背景、没有id、没有样式)。听起来您在描述其子元素之前关闭了LinearLayout元素。你需要发布你输入的内容,因为它不可能是我给你的。