本文整理汇总了Java中com.google.android.gms.ads.formats.NativeAppInstallAdView类的典型用法代码示例。如果您正苦于以下问题:Java NativeAppInstallAdView类的具体用法?Java NativeAppInstallAdView怎么用?Java NativeAppInstallAdView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NativeAppInstallAdView类属于com.google.android.gms.ads.formats包,在下文中一共展示了NativeAppInstallAdView类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:googlecodelabs,项目名称:admob-native-advanced-feed,代码行数:19,代码来源:NativeAppInstallAdViewHolder.java
示例2: onBindViewHolder
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
if (viewHolder==null)
return;
int itemViewType = viewHolder.getItemViewType();
if(itemViewType == getViewTypeAdInstall()) {
NativeAppInstallAdView lvi1 = (NativeAppInstallAdView) viewHolder.itemView;
NativeAppInstallAd ad1 = (NativeAppInstallAd) getItem(position);
getInstallAdsLayoutContext().bind(lvi1, ad1);
}
else if(itemViewType == getViewTypeAdContent()) {
NativeContentAdView lvi2 = (NativeContentAdView) viewHolder.itemView;
NativeContentAd ad2 = (NativeContentAd) getItem(position);
getContentAdsLayoutContext().bind(lvi2, ad2);
}
else{
int origPos = AdapterCalculator.getOriginalContentPosition(position,
adFetcher.getFetchedAdsCount(), mAdapter.getItemCount());
mAdapter.onBindViewHolder(viewHolder, origPos);
}
}
开发者ID:clockbyte,项目名称:admobadapter,代码行数:22,代码来源:AdmobRecyclerAdapterWrapper.java
示例3: getAppInstallAdViewHolder
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
public AppInstallAdViewHolder getAppInstallAdViewHolder() {
// There is no instance in which this will be called before getView(), so there is
// no reason getTag() should ever return a null value.
AdViewHolder holder = (AdViewHolder) mFrame.getTag();
if (holder instanceof AppInstallAdViewHolder) {
return (AppInstallAdViewHolder) holder;
} else {
mFrame.removeAllViews();
LayoutInflater inflater = (LayoutInflater) mFrame.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
NativeAppInstallAdView adView = (NativeAppInstallAdView) inflater
.inflate(R.layout.item_app_install_ad, mFrame, false);
mFrame.addView(adView);
AppInstallAdViewHolder appInstallAdViewHolder = new AppInstallAdViewHolder(adView);
mFrame.setTag(appInstallAdViewHolder);
return appInstallAdViewHolder;
}
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:23,代码来源:MultiFormatAdPlacement.java
示例4: onBindViewHolder
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
/**
* Replaces the content in the views that make up the menu item view and the
* Native Express ad view. This method is invoked by the layout manager.
*/
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
int viewType = getItemViewType(position);
switch (viewType) {
case NATIVE_APP_INSTALL_AD_VIEW_TYPE:
NativeAppInstallAd appInstallAd = (NativeAppInstallAd) mRecyclerViewItems.get(position);
populateAppInstallAdView(appInstallAd, (NativeAppInstallAdView) holder.itemView);
break;
case NATIVE_CONTENT_AD_VIEW_TYPE:
NativeContentAd contentAd = (NativeContentAd) mRecyclerViewItems.get(position);
populateContentAdView(contentAd, (NativeContentAdView) holder.itemView);
break;
case MENU_ITEM_VIEW_TYPE:
// fall through
default:
MenuItemViewHolder menuItemHolder = (MenuItemViewHolder) holder;
MenuItem menuItem = (MenuItem) mRecyclerViewItems.get(position);
// Get the menu item image resource ID.
String imageName = menuItem.getImageName();
int imageResID = mContext.getResources().getIdentifier(imageName, "drawable",
mContext.getPackageName());
// Add the menu item details to the menu item view.
menuItemHolder.menuItemImage.setImageResource(imageResID);
menuItemHolder.menuItemName.setText(menuItem.getName());
menuItemHolder.menuItemPrice.setText(menuItem.getPrice());
menuItemHolder.menuItemCategory.setText(menuItem.getCategory());
menuItemHolder.menuItemDescription.setText(menuItem.getDescription());
}
}
开发者ID:googlecodelabs,项目名称:admob-native-advanced-feed,代码行数:36,代码来源:RecyclerViewAdapter.java
示例5: populateAppInstallAdView
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
private void populateAppInstallAdView(NativeAppInstallAd nativeAppInstallAd,
NativeAppInstallAdView adView) {
// Some assets are guaranteed to be in every NativeAppInstallAd.
((ImageView) adView.getIconView()).setImageDrawable(nativeAppInstallAd.getIcon()
.getDrawable());
((TextView) adView.getHeadlineView()).setText(nativeAppInstallAd.getHeadline());
((TextView) adView.getBodyView()).setText(nativeAppInstallAd.getBody());
((Button) adView.getCallToActionView()).setText(nativeAppInstallAd.getCallToAction());
// These assets aren't guaranteed to be in every NativeAppInstallAd, so it's important to
// check before trying to display them.
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);
}
// Assign native ad object to the native view.
adView.setNativeAd(nativeAppInstallAd);
}
开发者ID:googlecodelabs,项目名称:admob-native-advanced-feed,代码行数:37,代码来源:RecyclerViewAdapter.java
示例6: 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);
}
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:13,代码来源:SampleAdMobNativeAd.java
示例7: getView
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
/**
* Creates or reuses a {@link FrameLayout} for this ad placement, filling it asynchronously
* with the assets for its {@link com.google.android.gms.ads.formats.NativeAppInstallAd}.
*
* @param convertView a {@link View} to reuse if possible
* @param parent The {@link ViewGroup} into which the {@link View} will be placed
* @return a {@link FrameLayout} that contains or will contain the ad assets for this placement
*/
@Override
public View getView(View convertView, ViewGroup parent) {
// For each native ad, a FrameLayout is created and returned to the ListView as
// the item's root view. This allows the fetcher to asynchronously request an ad, which
// will be converted into a set of Views and placed into the FrameLayout by the
// ViewHolder object.
FrameLayout frameLayout = (FrameLayout) convertView;
AppInstallAdViewHolder holder
= (frameLayout == null) ? null : (AppInstallAdViewHolder) frameLayout.getTag();
// If the holder is null, either this is the first time the item has been displayed, or
// convertView held a different type of item before. In either case, a new FrameLayout
// and ViewHolder should be created and used.
if (holder == null) {
frameLayout = new FrameLayout(parent.getContext());
LayoutInflater inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
NativeAppInstallAdView adView = (NativeAppInstallAdView) inflater
.inflate(R.layout.item_app_install_ad, frameLayout, false);
frameLayout.addView(adView);
holder = new AppInstallAdViewHolder(adView);
frameLayout.setTag(holder);
}
// This statement kicks off the ad loading process. The ViewHolder has some interface
// methods that will be invoked when the ad is ready to be displayed or fails to load.
mFetcher.loadAd(frameLayout.getContext(), holder);
// The FrameLayout is returned to the ListView so it will have something to show for the
// item right now. The FrameLayout will be filled with native ad assets later, once the
// ad has finished loading.
return frameLayout;
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:45,代码来源:AppInstallAdPlacement.java
示例8: AppInstallAdViewHolder
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
/**
* Stores the View for a {@link NativeAppInstallAd} and locates specific {@link View}s used
* to display its assets.
*
* @param adView the {@link View} used to display assets for a native app install ad.
*/
public AppInstallAdViewHolder(NativeAppInstallAdView adView) {
mAdView = adView;
mAdView.setHeadlineView(mAdView.findViewById(R.id.appinstall_headline));
mAdView.setImageView(mAdView.findViewById(R.id.appinstall_image));
mAdView.setBodyView(mAdView.findViewById(R.id.appinstall_body));
mAdView.setCallToActionView(mAdView.findViewById(R.id.appinstall_call_to_action));
mAdView.setIconView(mAdView.findViewById(R.id.appinstall_app_icon));
mAdView.setPriceView(mAdView.findViewById(R.id.appinstall_price));
mAdView.setStarRatingView(mAdView.findViewById(R.id.appinstall_stars));
mAdView.setStoreView(mAdView.findViewById(R.id.appinstall_store));
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:19,代码来源:AppInstallAdViewHolder.java
示例9: 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));
}
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:80,代码来源:MainActivity.java
示例10: trackView
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
@Override
public void trackView(final View view) {
view.post(new Runnable() {
@Override
public void run() {
if (view instanceof NativeAppInstallAdView) {
NativeAppInstallAdView appInstallAdView = (NativeAppInstallAdView) view;
final ArrayList<View> assetViews = new ArrayList<>();
if (appInstallAdView.getHeadlineView() != null) {
assetViews.add(appInstallAdView.getHeadlineView());
}
if (appInstallAdView.getBodyView() != null) {
assetViews.add(appInstallAdView.getBodyView());
}
if (appInstallAdView.getCallToActionView() != null) {
assetViews.add(appInstallAdView.getCallToActionView());
}
if (appInstallAdView.getIconView() != null) {
assetViews.add(appInstallAdView.getIconView());
}
if (appInstallAdView.getImageView() != null) {
assetViews.add(appInstallAdView.getImageView());
}
if (appInstallAdView.getPriceView() != null) {
assetViews.add(appInstallAdView.getPriceView());
}
if (appInstallAdView.getStarRatingView() != null) {
assetViews.add(appInstallAdView.getStarRatingView());
}
if (appInstallAdView.getStoreView() != null) {
assetViews.add(appInstallAdView.getStoreView());
}
if (appInstallAdView.getMediaView() != null) {
assetViews.add(mediaAdView);
}
nativeAd.registerView(view, assetViews);
} else {
Log.w(TAG, "Failed to register view for interaction.");
}
}
});
}
开发者ID:googleads,项目名称:googleads-mobile-android-mediation,代码行数:54,代码来源:MyTargetNativeAdapter.java
示例11: 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);
}
开发者ID:clockbyte,项目名称:admobadapter,代码行数:48,代码来源:InstallAppAdLayoutContext.java
示例12: prepare
import com.google.android.gms.ads.formats.NativeAppInstallAdView; //导入依赖的package包/类
/**
* To render ad view properly, implementation is expected to call {@link NativeAppInstallAdView#setHeadlineView(View)}, {@link NativeAppInstallAdView#setBodyView(View)}, {@link NativeAppInstallAdView#setCallToActionView(View)}, {@link NativeAppInstallAdView#setImageView(View)}, {@link NativeAppInstallAdView#setIconView(View)}, and/or {@link NativeAppInstallAdView#setStarRatingView(View)} methods,
* and render the ad view text/images using {@link NativeAppInstallAd#getHeadline()}, {@link NativeAppInstallAd#getBody()}, {@link NativeAppInstallAd#getCallToAction()}, {@link NativeAppInstallAd#getImages()}, {@link NativeAppInstallAd#getIcon()}, and/or {@link NativeAppInstallAd#getStarRating()} methods.
* @param adView The native ad view to render the ad.
* @param nativeAd The native ad instance used to render the ad view.
*/
protected abstract void prepare(@NonNull NativeAppInstallAdView adView, @NonNull NativeAppInstallAd nativeAd);
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:8,代码来源:AdMobNativeAd.java
注:本文中的com.google.android.gms.ads.formats.NativeAppInstallAdView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论