[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eNative and banner ads can be combined in ad requests with code modifications, using the \u003ccode\u003eAdLoader\u003c/code\u003e class for loading.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAdLoader\u003c/code\u003e is configured to handle both native and banner ads, using listeners to manage each format.\u003c/p\u003e\n"],["\u003cp\u003eBanner ads requested through \u003ccode\u003eAdLoader\u003c/code\u003e should be accompanied by native ad requests and do not refresh automatically.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eAdManagerAdViewOptions\u003c/code\u003e allow customization of banner behavior, including manual impression reporting.\u003c/p\u003e\n"]]],["To combine native and banner ads in requests, use the `AdLoader` class with the Google Mobile Ads SDK (v11.0.0+). Build `AdLoader` with `forNativeAd` and `forAdManagerAdView` listeners to specify ad types. For banner ads, specify valid ad sizes with `OnAdManagerAdViewLoadedListener`. Use `withAdManagerAdViewOptions` to set banner-specific options like `setManualImpressionsEnabled()`. Note: Banner ads must be requested with native ads via `AdLoader`, and do not refresh when loaded this way.\n"],null,["With a few changes to your code, you can combine native and banner ads in your\nad requests.\n\nPrerequisites\n\n- Version 11.0.0 or higher of the Google Mobile Ads SDK.\n\n- Complete the [Get started guide](/ad-manager/mobile-ads-sdk/android/quick-start).\n\nLoad an ad\n\nCustom-rendered native ads are loaded using the `AdLoader` class, which has its\nown `AdLoader.Builder` class to customize it during creation. By adding\nlisteners to the `AdLoader` while building it, an app specifies which types of\nad formats it is ready to receive. The `AdLoader` then requests just those\ntypes.\n\nThe `AdLoader` object can also be configured to make ad requests that can result\nin either a banner ad or a native ad. Adding an\n`OnAdManagerAdViewLoadedListener` to the `AdLoader` while building it specifies\nthat banner ads should compete with native ads to fill the request.\n\nThe following code demonstrates how to build an `AdLoader` that can load either\na native or banner ad in a single request: \n\nJava \n\n```java\nAdLoader adLoader = new AdLoader.Builder(context, \"/21775744923/example/native-and-banner\")\n .forNativeAd(new NativeAd.OnNativeAdLoadedListener() {\n @Override\n public void onNativeAdLoaded(NativeAd nativeAd) {\n // Show the ad.\n }\n })\n .forAdManagerAdView(new OnAdManagerAdViewLoadedListener() {\n @Override\n public void onAdManagerAdViewLoaded(AdManagerAdView adView) {\n // Show the banner ad.\n }\n }, AdSize.BANNER, AdSize.MEDIUM_RECTANGLE)\n .withAdListener(new AdListener() {\n @Override\n public void onAdFailedToLoad(LoadAdError error) {\n // Handle the failure by logging, altering the UI, etc.\n }\n })\n .withAdManagerAdViewOptions(new AdManagerAdViewOptions.Builder()\n // Methods in the AdManagerAdViewOptions.Builder class can be\n // used here to specify individual options settings.\n .build())\n .build();\n```\n\nKotlin \n\n```kotlin\nval adLoader = AdLoader.Builder(this, \"/21775744923/example/native-and-banner\")\n .forNativeAd { nativeAd -\u003e\n // Show the ad.\n }\n .forAdManagerAdView({ adView -\u003e\n // Show the banner ad.\n }, AdSize.BANNER, AdSize.MEDIUM_RECTANGLE)\n .withAdListener(object: AdListener() {\n override fun onAdFailedToLoad(adError: LoadAdError) {\n // Handle the failure by logging, altering the UI, etc.\n }\n })\n .withAdManagerAdViewOptions(AdManagerAdViewOptions.Builder()\n // Methods in the AdManagerAdViewOptions.Builder class can be\n // used here to specify individual options settings.\n .build())\n .build()\n```\n\nThe `forAdManagerAdView()` method prepares the `AdLoader` to receive banner ads.\nA variable-length list of valid ad sizes must be specified alongside an\n`OnAdManagerAdViewLoadedListener` when invoking `forAdManagerAdView()`.\n\nTo make a valid ad request, at least one valid ad size must be specified. When a\nbanner ad has loaded successfully, the specified listener object's\n`onAdManagerAdViewLoaded()` method is called.\n| **Key Point:** Banner ads can only be loaded through `AdLoader` objects when requested alongside native ads. To make an ad request for banners alone, follow the steps outlined in the in [Banner\n| Ads](/ad-manager/mobile-ads-sdk/android/banner). In addition, banners loaded through `AdLoader` objects don't refresh.\n\nSet the AdViewOptions object\n\nThe last function included in the creation of the `AdLoader` is another optional\nmethod, `withAdManagerAdViewOptions()`: \n\nJava \n\n```java\n.withAdManagerAdViewOptions(new AdManagerAdViewOptions.Builder()\n // Methods in the AdManagerAdViewOptions.Builder class can be\n // used here to specify individual banner options settings.\n .build()\n```\n\nKotlin \n\n```kotlin\n.withAdManagerAdViewOptions(AdManagerAdViewOptions.Builder()\n // Methods in the AdManagerAdViewOptions.Builder class can be\n // used here to specify individual banner options settings.\n .build()\n```\n\nThe `AdManagerAdViewOptions` object lets publishers set specific options for\nbanners loaded by the `AdLoader`, such as:\n\n`setManualImpressionsEnabled()`\n: Enables manual impression reporting for Google\n Ad Manager reservations. Apps using manual impressions can determine for\n themselves when an impression should be recorded, and can do so by calling\n `AdManagerAdView.recordManualImpression()`.\n\n\u003cbr /\u003e"]]