本文整理匯總了Java中com.google.android.gms.ads.AdView.setVisibility方法的典型用法代碼示例。如果您正苦於以下問題:Java AdView.setVisibility方法的具體用法?Java AdView.setVisibility怎麽用?Java AdView.setVisibility使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.ads.AdView
的用法示例。
在下文中一共展示了AdView.setVisibility方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupGoogleAds
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private void setupGoogleAds() {
mAdView = (AdView) findViewById(R.id.adView);
if (mAdView != null) {
mAdView.setVisibility(View.GONE);
if (!isPro()) {
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
mAdView.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
mAdView.setVisibility(View.GONE);
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
mAdView.setVisibility(View.VISIBLE);
}
});
mAdView.loadAd(adRequest);
if (!checkDataConnection()) {
mAdView.setVisibility(View.GONE);
}
}
}
}
示例2: onSharedPreferenceChanged
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(mContext.getString(R.string.pref_ads_enabled))) {
mAdsEnabled = sharedPreferences.getBoolean(
mContext.getString(R.string.pref_ads_enabled), true
);
for (AdView adView : mAdViews) {
adView.setVisibility(mAdsEnabled ? View.VISIBLE : View.GONE);
if (mAdsEnabled && !((AppearAdListener) adView.getAdListener()).isLoaded()) {
adView.loadAd(new AdRequest.Builder().build());
}
}
}
}
示例3: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
load();
a = (RelativeLayout) findViewById(R.id.lay);
mAdView = (AdView) findViewById(R.id.adView);
mAdView.setVisibility(View.GONE);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
mAdView.setVisibility(View.VISIBLE);
}
});
}
示例4: onCreateView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//Create the AdView fragment container layout
View v = inflater.inflate(R.layout.fragment_ad, container, false);
//Generate the AdView and configure it
mAdView = new AdView(v.getContext());
mAdView.setVisibility(View.GONE);
RelativeLayout.LayoutParams mAdViewLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
mAdView.setLayoutParams(mAdViewLayout);
//...set the Ads info
mAdView.setAdSize(adSize);
mAdView.setAdUnitId(adUnitId);
//Add the AdView to the fragment container layout :)
((RelativeLayout)v).addView(mAdView);
return v;
}
示例5: loadAdViewIfNeed
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
protected void loadAdViewIfNeed() {
try {
mAdView = (AdView) findViewById(R.id.ad_view);
if (mAdView != null) {
if (BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
mAdView.setVisibility(View.GONE);
} else {
mAdView.loadAd(new AdRequest.Builder().build());
}
}
} catch (Exception e) {
//class cast
}
}
示例6: adHandling
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public void adHandling(View rootView) {
// Ads
if (((AnalyticsApplication) ac.getApplication()).isGooglePlayBuild()) {
AdView mAdView = (AdView) rootView.findViewById(R.id.adView);
if (Settings.displayAds) {
MobileAds.initialize(ac, "ca-app-pub-8285849835347571~6235180375");
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
} else {
mAdView.setVisibility(View.GONE);
}
}
}
示例7: setupAds
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
public static void setupAds(Activity activity, @IdRes int adViewId) {
AdView adView = (AdView) activity.findViewById(adViewId);
if (Flavours.type == Flavours.Type.FREE) {
adView.setVisibility(View.VISIBLE);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
} else {
adView.setVisibility(View.GONE);
}
}
示例8: initBannerAd
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
public static void initBannerAd(Context context, AdView adView){
if(App.isPro(context) || BuildConfig.DEBUG){
adView.setVisibility(View.GONE);
} else {
adView.loadAd(getAdRequest(context));
}
}
示例9: setupAds
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
public void setupAds() {
adView = new AdView(this);
adView.setVisibility(View.VISIBLE);
adView.setBackgroundColor(0xff000000); //d7d7d7
adView.setAdUnitId(AD_UNIT_ID_BANNER);
adView.setAdSize(AdSize.SMART_BANNER);
}
示例10: admobVisibility
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
public static boolean admobVisibility(AdView ad, boolean isInDebugMode){
if(isInDebugMode) {
ad.setVisibility(View.VISIBLE);
return true;
}else {
ad.setVisibility(View.GONE);
return false;
}
}
示例11: onPurchasesUpdated
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
public void onPurchasesUpdated(@BillingClient.BillingResponse int responseCode, List<Purchase> purchases) {
if (responseCode == BillingClient.BillingResponse.OK && purchases != null) {
if(getView() != null) {
// Apply preference
SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("donationPurchased", true);
editor.apply();
// Destroy Ad
AdView mAdView = getActivity().findViewById(R.id.adView);
mAdView.setVisibility(GONE);
mAdView.destroy();
showDonatorStatus();
}
} else if (responseCode == BillingClient.BillingResponse.USER_CANCELED) {
// Handle an error caused by a user cancelling the purchase flow.
if(getView() != null) {
Snackbar.make(getView(), R.string.donation_cancelled, Snackbar.LENGTH_SHORT).show();
}
} else {
// Handle any other error codes.
if(getView() != null) {
Snackbar.make(getView(), R.string.donation_cancelled, Snackbar.LENGTH_SHORT).show();
}
}
}
示例12: executeAdView
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
public AdsManager executeAdView(AdView adView) {
if (BuildConfig.DEBUG && !showAdsOnDebug) {
adView.setVisibility(View.GONE);
} else {
final AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
adRequestBuilder.addTestDevice(DeviceIdFounder.getDeviceId(context));
}
adView.loadAd(adRequestBuilder.build());
adViewList.add(adView);
}
return this;
}
示例13: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.voting);
setupActionBar();
AdView adView = (AdView) this.findViewById(R.id.adView);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("ads", true)) {
adView.setVisibility(View.VISIBLE);
Bundle bundle = new Bundle();
bundle.putString("color_bg", "4285f4");
bundle.putString("color_bg_top", "4285f4");
bundle.putString("color_border", "4285f4");
bundle.putString("color_link", "EEEEEE");
bundle.putString("color_text", "FFFFFF");
bundle.putString("color_url", "EEEEEE");
AdMobExtras extras = new AdMobExtras(bundle);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("E9439BFF2245E1BC1DD0FDB28EA467F9").addTestDevice("49924C4BF3738C69A7497A524D092901").addNetworkExtras(extras).build();
adView.loadAd(adRequest);
} else {
adView.setVisibility(View.GONE);
}
progress = (ProgressBar) findViewById(R.id.progressBar);
Parse.initialize(this, "giwroIjJIvqQCpTB23LsdDYe8HdHCxZwy0fkKksV", "H98VqurfJTM4J05D8Fmht3VyXdbTCb5ghBf8Jkjc");
((FloatingActionButton)findViewById(R.id.suggest)).attachToListView(((AbsListView)findViewById(R.id.card_list_view)));
}
示例14: onCreate
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.most_wanted);
setupActionBar();
AdView adView = (AdView) this.findViewById(R.id.adView);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("ads", true)) {
adView.setVisibility(View.VISIBLE);
Bundle bundle = new Bundle();
bundle.putString("color_bg", "4285f4");
bundle.putString("color_bg_top", "4285f4");
bundle.putString("color_border", "4285f4");
bundle.putString("color_link", "EEEEEE");
bundle.putString("color_text", "FFFFFF");
bundle.putString("color_url", "EEEEEE");
AdMobExtras extras = new AdMobExtras(bundle);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("E9439BFF2245E1BC1DD0FDB28EA467F9").addTestDevice("49924C4BF3738C69A7497A524D092901").addNetworkExtras(extras).build();
adView.loadAd(adRequest);
} else {
adView.setVisibility(View.GONE);
}
ArrayList<Card> cards = new ArrayList<Card>();
for (MostWantedCommand command : MostWantedCommands.getCommands(this)) {
cards.add(new MostWantedCard(this, command));
}
CardGridArrayAdapter mCardArrayAdapter = new CardGridArrayAdapter(this, cards);
final CardGridView listView = (CardGridView) findViewById(R.id.card_list_view);
((FloatingActionButton)findViewById(R.id.vote)).attachToListView(listView);
SwingBottomInAnimationAdapter animCardArrayAdapter = new SwingBottomInAnimationAdapter(mCardArrayAdapter);
animCardArrayAdapter.setAbsListView(listView);
listView.setExternalAdapter(animCardArrayAdapter, mCardArrayAdapter);
findViewById(R.id.vote).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MostWantedCommandsActivity.this, VotingActivity.class));
}
});
}
示例15: handleAds
import com.google.android.gms.ads.AdView; //導入方法依賴的package包/類
private void handleAds(AdView adView) {
//if ad info not available do not try to get ads
if (Preferences.getInstance(getActivity()).getAdmobBannerId().length() == 0)
return;
adView.setVisibility(View.VISIBLE);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}