gpt4 book ai didi

android - 使用 adMob 无法在 Android 上展示广告

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:09:55 25 4
gpt4 key购买 nike

我已将相关部分包含在我的 list 中:

<meta-data android:value="123456789" android:name="ADMOB_PUBLISHER_ID" />

<!-- Track Market installs from AdMob ads -->
<receiver android:name="com.admob.android.ads.analytics.InstallReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />'

<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>'

从示例中直接复制的属性:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.admob.android.ads.AdView">
<attr name="backgroundColor" format="color" />
<attr name="primaryTextColor" format="color" />
<attr name="secondaryTextColor" format="color" />
<attr name="keywords" format="string" />
<attr name="refreshInterval" format="integer" />
</declare-styleable>
</resources>

我的布局(顺便说一句,这是一个选项卡 View )是一个表格,它在自己的行中:

xmlns:app="http://schemas.android.com/apk/res/com.icukansas.lenscalculator"

<TableRow>
<!-- Place an AdMob ad at the bottom of the screen. -->
<!-- It has white text on a black background. -->
<com.admob.android.ads.AdView
android:layout_span="4"
android:id="@+id/ad"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC"
app:keywords="security"
/>
</TableRow>

然后我调用:

public class myClass extends Activity implements AdListener{

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    setContentView(R.layout.tab_thistab);

AdView ad = (AdView) findViewById(R.id.ad);
ad.setAdListener(this);

每次我在日志中收到 onFailedToReceiveAd 错误。

我确定它很容易丢失 :)

最佳答案

我知道这是旧的,但我认为它对尝试在表格布局中放置广告的人会有所帮助。我最终通过在我的 TableLayout 中包含 android:stretchColumns="0,1,2,3"使它起作用。如果您的跨度不是 4,您将在 stretchColumns 中放置与您的跨度相同数量的列/数字。

<TableLayout android:id="@+id/TableLayout01" android:stretchColumns="0,1,2,3" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">

关于android - 使用 adMob 无法在 Android 上展示广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3436021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com