---
description: Integrate native ads (Huawei)
---

# Native Ads: Huawei

NativeView

* Native ad assets of Huawei SDK are required to be encapsulated within a parent view of a specific type `com.huawei.hms.ads.nativead.NativeView`.
* The same view must be passed to AATKit via the `NativeAdData` method: `attachToLayout`.

Also, Huawei displays the native ad main image using an instance of `com.huawei.hms.ads.nativead.MediaView`.

{% tabs %}
{% tab title="Java" %}
```java
private com.huawei.hms.ads.nativead.NativeView containerView;
private TextView titleView;
private TextView descriptionView;
private com.huawei.hms.ads.nativead.MediaView mediaView;
private ImageView iconView;
private TextView ctaView;
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
private var containerView: com.huawei.hms.ads.nativead.NativeView? = null
private var titleView: TextView? = null
private var descriptionView: TextView? = null
private var mediaView: com.huawei.hms.ads.nativead.MediaView? = null
private var iconView: ImageView? = null
private var ctaView: TextView? = null
```
{% endtab %}
{% endtabs %}

**Bind Huawei Native Ad Assets**

After getting a native ad from the `NativeAdPlacement`, you can follow this code example to bind the native ad assets:

{% tabs %}
{% tab title="Java" %}
```java
private void setupHuaweiAd(NativeAdData nativeAd) {
    // TODO: create the container view and subviews from layout file

    // Title
    containerView.setTitleView(titleView);
    titleView.setText(nativeAd.getTitle());

    // Ad Icon
    containerView.setIconView(iconView);
    loadImage(iconView, nativeAd.getIconUrl());

    // Body
    containerView.setAdSourceView(descriptionView);
    descriptionView.setText(nativeAd.getDescription());

    // MediaView
    containerView.setMediaView(mediaView); //Huawei SDK will fill the passed MediaView automatically

    // CallToAction
    containerView.setCallToActionView(ctaView);
    ctaView.setText(nativeAd.getCallToAction());

    nativeAd.attachToLayout(containerView, mediaView, iconView, ctaView);
}
```
{% endtab %}

{% tab title="Kotlin" %}
```kotlin
private fun setupHuaweiAd(nativeAd: NativeAdData) {
    // TODO: create the container view and subviews from layout file

    // Title
    containerView.setTitleView(titleView)
    titleView.text = nativeAd.title

    // Ad Icon
    containerView.setIconView(iconView)
    loadImage(iconView, nativeAd.iconUrl)

    // Body
    containerView.setAdSourceView(descriptionView)
    descriptionView.text = nativeAd.description

    // MediaView
    containerView.setMediaView(mediaView) //Huawei SDK will fill the passed MediaView automatically

    // CallToAction
    containerView.setCallToActionView(ctaView)
    ctaView.text = nativeAd.callToAction
    
    nativeAd.attachToLayout(containerView, mediaView, iconView, ctaView)
}
```
{% endtab %}
{% endtabs %}
