本文整理汇总了Java中com.google.android.gms.ads.formats.NativeAppInstallAdView.findViewById方法的典型用法代码示例。如果您正苦于以下问题:Java NativeAppInstallAdView.findViewById方法的具体用法?Java NativeAppInstallAdView.findViewById怎么用?Java NativeAppInstallAdView.findViewById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.formats.NativeAppInstallAdView
的用法示例。
在下文中一共展示了NativeAppInstallAdView.findViewById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: NativeAppInstallAdViewHolder
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入方法依赖的package包/类
NativeAppInstallAdViewHolder(View view) {
super(view);
NativeAppInstallAdView adView = (NativeAppInstallAdView) view;
// The MediaView will display a video asset if one is present in the ad, and the
// first image asset otherwise.
MediaView mediaView = (MediaView) adView.findViewById(R.id.appinstall_media);
adView.setMediaView(mediaView);
// Register the view used for each individual asset.
adView.setHeadlineView(adView.findViewById(R.id.appinstall_headline));
adView.setBodyView(adView.findViewById(R.id.appinstall_body));
adView.setCallToActionView(adView.findViewById(R.id.appinstall_call_to_action));
adView.setIconView(adView.findViewById(R.id.appinstall_app_icon));
adView.setPriceView(adView.findViewById(R.id.appinstall_price));
adView.setStarRatingView(adView.findViewById(R.id.appinstall_stars));
adView.setStoreView(adView.findViewById(R.id.appinstall_store));
}
示例2: prepare
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入方法依赖的package包/类
@Override
protected void prepare(@NonNull final NativeAppInstallAdView adView, @NonNull final NativeAppInstallAd nativeAd) {
final TextView adTitle = (TextView)adView.findViewById(R.id.ad_title);
final TextView adBody = (TextView)adView.findViewById(R.id.ad_body);
final ImageView adImage = (ImageView)adView.findViewById(R.id.ad_image);
final TextView adCallToAction = (TextView)adView.findViewById(R.id.ad_call_to_action);
adView.setHeadlineView(adTitle);
adView.setBodyView(adBody);
adView.setImageView(adImage);
adView.setCallToActionView(adCallToAction);
}
示例3: populateAppInstallAdView
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入方法依赖的package包/类
/**
* Populates a {@link NativeAppInstallAdView} object with data from a given
* {@link NativeAppInstallAd}.
*
* @param nativeAppInstallAd the object containing the ad's assets
* @param adView the view to be populated
*/
private void populateAppInstallAdView(NativeAppInstallAd nativeAppInstallAd,
NativeAppInstallAdView adView) {
VideoController videoController = nativeAppInstallAd.getVideoController();
// Assign native ad object to the native view.
adView.setNativeAd(nativeAppInstallAd);
adView.setHeadlineView(adView.findViewById(R.id.appinstall_headline));
adView.setBodyView(adView.findViewById(R.id.appinstall_body));
adView.setCallToActionView(adView.findViewById(R.id.appinstall_call_to_action));
adView.setIconView(adView.findViewById(R.id.appinstall_app_icon));
adView.setPriceView(adView.findViewById(R.id.appinstall_price));
adView.setStarRatingView(adView.findViewById(R.id.appinstall_stars));
adView.setStoreView(adView.findViewById(R.id.appinstall_store));
// Some assets are guaranteed to be in every NativeAppInstallAd.
((TextView) adView.getHeadlineView()).setText(nativeAppInstallAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeAppInstallAd.getBody());
((Button) adView.getCallToActionView()).setText(nativeAppInstallAd.getCallToAction());
((ImageView) adView.getIconView()).setImageDrawable(nativeAppInstallAd.getIcon()
.getDrawable());
MediaView sampleMediaView = adView.findViewById(R.id.appinstall_media);
ImageView imageView = adView.findViewById(R.id.appinstall_image);
if (videoController.hasVideoContent()) {
imageView.setVisibility(View.GONE);
adView.setMediaView(sampleMediaView);
} else {
sampleMediaView.setVisibility(View.GONE);
adView.setImageView(imageView);
List<NativeAd.Image> images = nativeAppInstallAd.getImages();
if (images.size() > 0) {
((ImageView) adView.getImageView()).setImageDrawable(images.get(0).getDrawable());
}
}
// Some aren't guaranteed, however, and should be checked.
if (nativeAppInstallAd.getPrice() == null) {
adView.getPriceView().setVisibility(View.INVISIBLE);
} else {
adView.getPriceView().setVisibility(View.VISIBLE);
((TextView) adView.getPriceView()).setText(nativeAppInstallAd.getPrice());
}
if (nativeAppInstallAd.getStore() == null) {
adView.getStoreView().setVisibility(View.INVISIBLE);
} else {
adView.getStoreView().setVisibility(View.VISIBLE);
((TextView) adView.getStoreView()).setText(nativeAppInstallAd.getStore());
}
if (nativeAppInstallAd.getStarRating() == null) {
adView.getStarRatingView().setVisibility(View.INVISIBLE);
} else {
((RatingBar) adView.getStarRatingView())
.setRating(nativeAppInstallAd.getStarRating().floatValue());
adView.getStarRatingView().setVisibility(View.VISIBLE);
}
// Handle the fact that this could be a Sample SDK native ad, which includes a
// "degree of awesomeness" field.
Bundle extras = nativeAppInstallAd.getExtras();
if (extras.containsKey(SampleCustomEvent.DEGREE_OF_AWESOMENESS)) {
TextView degree = (TextView) adView.findViewById(R.id.appinstall_degreeofawesomeness);
degree.setVisibility(View.VISIBLE);
degree.setText(extras.getString(SampleCustomEvent.DEGREE_OF_AWESOMENESS));
}
}
示例4: bind
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入方法依赖的package包/类
@Override
public void bind(NativeAdView nativeAdView, NativeAd nativeAd) throws ClassCastException{
if (nativeAdView == null || nativeAd == null) return;
if(!(nativeAd instanceof NativeAppInstallAd) || !(nativeAdView instanceof NativeAppInstallAdView))
throw new ClassCastException();
NativeAppInstallAd ad = (NativeAppInstallAd) nativeAd;
NativeAppInstallAdView adView = (NativeAppInstallAdView) nativeAdView;
// Locate the view that will hold the headline, set its text, and call the
// NativeAppInstallAdView's setHeadlineView method to register it.
TextView tvHeader = (TextView) adView.findViewById(R.id.tvHeader);
tvHeader.setText(ad.getHeadline());
adView.setHeadlineView(tvHeader);
TextView tvDescription = (TextView) adView.findViewById(R.id.tvDescription);
tvDescription.setText(ad.getBody());
adView.setBodyView(tvDescription);
ImageView ivLogo = (ImageView) adView.findViewById(R.id.ivLogo);
if(ad.getIcon()!=null)
ivLogo.setImageDrawable(ad.getIcon().getDrawable());
adView.setIconView(ivLogo);
Button btnAction = (Button) adView.findViewById(R.id.btnAction);
btnAction.setText(ad.getCallToAction());
adView.setCallToActionView(btnAction);
TextView tvStore = (TextView) adView.findViewById(R.id.tvStore);
tvStore.setText(ad.getStore());
adView.setStoreView(tvStore);
TextView tvPrice = (TextView) adView.findViewById(R.id.tvPrice);
tvPrice.setText(ad.getPrice());
adView.setPriceView(tvPrice);
ImageView ivImage = (ImageView) adView.findViewById(R.id.ivImage);
if (ad.getImages() != null && ad.getImages().size() > 0) {
ivImage.setImageDrawable(ad.getImages().get(0).getDrawable());
ivImage.setVisibility(View.VISIBLE);
} else ivImage.setVisibility(View.GONE);
adView.setImageView(ivImage);
// Call the NativeAppInstallAdView's setNativeAd method to register the
// NativeAd.
adView.setNativeAd(ad);
}