> For the complete documentation index, see [llms.txt](https://docs.bidapp.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bidapp.io/plugins/kotlin-multiplatform/banner-ads.md).

# Banner Ads

To load a banner, create a `BannerView` and add it as a subview of your view hierarchy.

You can create banners of either **320x50, 300x250** or **728x90** size:

```kotlin

fun createBanner_320x50(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_320x50)
    banner.setBannerViewDelegate(bannerShowDelegate)
}

fun createBanner_300x250(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_300x250)
    banner.setBannerViewDelegate(bannerShowDelegate)
}

fun createBanner_728x90(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_728x90)
    banner.setBannerViewDelegate(bannerShowDelegate)
}
```

Implement `BIDBannerShow` so that you are notified of when your ad is ready and of other ad-related events.

<pre class="language-kotlin"><code class="lang-kotlin">//BIDBannerShow protocol methods 

var bannerShow: BIDBannerShow? = object : BIDBannerShow {
    override fun load(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - adViewDidLoadAd. AdView: $adView, AdInfo: $info")
<strong>    }
</strong>
    override fun display(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - didDisplayAd. AdView: $adView, AdInfo: $info")
    }

    override fun failToDisplay(info: BIDAdInfo, adView: BIDBanner, error: String) {
        print("Banner - didFailToDisplayAd. AdView: $adView, Error:$errors")
<strong>    }
</strong>
    override fun click(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - didClicked. AdView: $adView, AdInfo: $info")
    }

    override fun allNetworksFailedToDisplay(error: String) {
        print("Banner - allNetworksFailedToDisplayAd - error: $error")
<strong>    }
</strong><strong>}
</strong></code></pre>

To display a banner you will need to bind it to FrameLayout or ConstraintLayout for Android and UIView for iOS

<pre class="language-kotlin"><code class="lang-kotlin"><strong>banner.bindBanner(container)
</strong></code></pre>

## Stopping and Starting Auto-Refresh

There may be cases when you would like to stop auto-refresh, for instance, when you hide a banner ad or want to refresh it manually.

Stop auto-refresh for a banner ad with the following code:

```kotlin
banner.stopAutorefresh()
```

Start auto-refresh for a banner ad with the following code:

```kotlin
banner.startAutorefresh(30.0)
```

Manually refresh the contents with the following code. You must stop auto-refresh prior to calling `refreshAd`.

```kotlin
banner.refresh()
```

## Destroying Banners

Once you're finished with a banner ad, it's essential to clean up its resources by invoking the destroy() method. Neglecting this step could lead to a deterioration in your app's performance

{% tabs %}
{% tab title="Java" %}

```java
banner.destroy()
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
banner.destroy()
```

{% endtab %}
{% endtabs %}
