本文整理汇总了Java中com.google.android.gms.ads.AdView类的典型用法代码示例。如果您正苦于以下问题:Java AdView类的具体用法?Java AdView怎么用?Java AdView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AdView类属于com.google.android.gms.ads包,在下文中一共展示了AdView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_main, container, false);
AdView mAdView = (AdView) root.findViewById(R.id.adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device. e.g.
// "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
mAdView.loadAd(adRequest);
return root;
}
示例2: addAds
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
private void addAds() {
// add AdMob
AdView adView = new AdView(this);
adView.setAdUnitId(AD_UNIT_ID);
adView.setAdSize(AdSize.SMART_BANNER);
LinearLayout.LayoutParams adLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
adView.setLayoutParams(adLayoutParams);
// 広告表示位置は画面下部
LinearLayout layout = new LinearLayout(this);
layout.addView(adView);
layout.setGravity(Gravity.BOTTOM);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
addContentView(layout, layoutParams);
// load ad
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
示例3: onCreate
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(getApplicationContext(), "YOUR UNIT ID");
AdView adView = (AdView) this.findViewById(R.id.adMob);
//request TEST ads to avoid being disabled for clicking your own ads
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)// This is for emulators
//test mode on DEVICE (this example code must be replaced with your device uniquq ID)
// .addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC") // Nexus 5
.build();
adView.loadAd(adRequest);
}
示例4: initializeAds
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
public static void initializeAds(Context context, View bannerPlaceholder, AdView adView, AnalyticsHelper analyticsHelper, String screenName) {
initializeAds(context, adView);
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
apply(bannerPlaceholder, GONE);
apply(adView, VISIBLE);
}
@Override
public void onAdFailedToLoad(int i) {
analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
}
@Override
public void onAdClicked() {
analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
}
});
}
示例5: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.more_info_fragment, container, false);
ButterKnife.bind(this, mView);
auth.getCurrentUser();
Uri photoUrl = auth.getCurrentUser().getPhotoUrl();
Glide.with(this).load(photoUrl).into(imageView);
String strMeatFormat = getResources().getString(R.string.welcome_format);
String strMeatMsg = String.format(strMeatFormat, auth.getCurrentUser().getDisplayName());
mProfileName.setText(strMeatMsg);
adView = (AdView) mView.findViewById(R.id.adView);
AdRequest builder = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(builder);
return mView;
}
示例6: initView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
private void initView() {
mTabHeader = (TableLayout) findViewById(R.id.sql_tabview_header_tab);
mRecycleView = (FastScrollRecyclerView) findViewById(R.id.sql_tabview_recycleview);
mLinearLayoutManager = new LinearLayoutManager(SqlTabDatasActivity.this);
mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecycleView.setLayoutManager(mLinearLayoutManager);
mContent = (MyHorizontalScrollView) findViewById(R.id.content);
mRecycleView.setMinimumWidth(FeViewUtils.getScreenWidth(this));
mToolBar = (Toolbar) findViewById(R.id.toolbar);
mAdmobLayout = (RelativeLayout) findViewById(R.id.admob_layout);
mRootLayout = (RelativeLayout) findViewById(R.id.rootLayout);
mAdView = (AdView) findViewById(R.id.adView);
mAdMobBgBtn = (Button) findViewById(R.id.admob_bg_btn);
mAdClose = (ImageView) findViewById(R.id.admob_close);
btn = (FloatingActionButton) findViewById(R.id.fab);
mTabHeader.setBackground(getResources().getDrawable(R.color.table_head_bg));
if (dataSource != SqlConstant.TABLE_DATAS_NORMAL) {
btn.setVisibility(View.GONE);
} else {
btn.setVisibility(View.VISIBLE);
}
resultHandler = new SqlActivityResultHandler(this);
}
示例7: initView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
protected void initView() {
mRecycleView = (RecyclerView) findViewById(R.id.sql_tabs_recycleview);
mSwipeRefresh = (FeSwipeRefreshLayout) findViewById(R.id.recycler_view_container);
mSwipeRefresh.setProgressViewOffset(true, -20, 150);
toolbar = (Toolbar) findViewById(R.id.toolbar);
mFab = (FloatingActionButton) findViewById(R.id.mFab);
mMenu = (FloatingActionMenu) findViewById(R.id.mFam);
mCreateNewTab = (FloatingActionButton) findViewById(R.id.sql_btn_create_tab);
mImportTab = (FloatingActionButton) findViewById(R.id.sql_btn_import_tab);
mAdView = (AdView) findViewById(R.id.adView);
mAdBg = (Button) findViewById(R.id.admob_bg_btn);
mAdClose = (ImageView) findViewById(R.id.admob_close);
mAdmobLayout = (RelativeLayout) findViewById(R.id.admob_layout);
mRootLayout = (RelativeLayout) findViewById(R.id.roottabslayout);
mMenu.setClosedOnTouchOutside(true);
}
示例8: enableAds
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
private void enableAds() {
RelativeLayout rlAd = (RelativeLayout) findViewById(R.id.rlAd);
LinearLayout llAd = (LinearLayout) findViewById(R.id.llAd);
final AdView adView = (AdView) findViewById(R.id.adView);
rlAd.setVisibility(View.VISIBLE);
llAd.setVisibility(View.VISIBLE);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
try {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(getString(R.string.ad_test_device_id))
.build();
adView.loadAd(adRequest);
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
}
}, 1000);
}
示例9: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz15, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques15);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例10: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz5, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques5);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例11: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz9, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques9);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例12: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_quiz3, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)v.findViewById(R.id.adViewques3);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return v;
}
示例13: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz13, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques13);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例14: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_quiz10, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)view.findViewById(R.id.adViewques10);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return view;
}
示例15: onCreateView
import com.google.android.gms.ads.AdView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_quiz2, container, false);
String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
String deviceId = md5(android_id).toUpperCase();
Log.i("device id=",deviceId);
AdView adView = (AdView)v.findViewById(R.id.adViewques2);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(deviceId)
.build();
adView.loadAd(adRequest);
return v;
}