After getting a native ad from the NativeAdPlacement, you can follow this code example to bind the native ad assets:
privatevoidsetupHuaweiAd(NativeAdData nativeAd) {// TODO: create the container view and subviews from layout file// TitlecontainerView.setTitleView(titleView);titleView.setText(nativeAd.getTitle());// Ad IconcontainerView.setIconView(iconView);loadImage(iconView,nativeAd.getIconUrl());// BodycontainerView.setAdSourceView(descriptionView);descriptionView.setText(nativeAd.getDescription());// MediaViewcontainerView.setMediaView(mediaView); //Huawei SDK will fill the passed MediaView automatically// CallToActioncontainerView.setCallToActionView(ctaView);ctaView.setText(nativeAd.getCallToAction());nativeAd.attachToLayout(containerView, mediaView, iconView, ctaView);}
privatefunsetupHuaweiAd(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)}