當前位置: 首頁>>代碼示例>>Java>>正文


Java AdView.setVisibility方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:niranjan94,項目名稱:show-java,代碼行數:27,代碼來源:BaseActivity.java

示例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());
            }
        }
    }
}
 
開發者ID:Longi94,項目名稱:bptf,代碼行數:17,代碼來源:AdManager.java

示例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);
        }
    });

}
 
開發者ID:rulogarcillan,項目名稱:SignatureMaker,代碼行數:19,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:javocsoft,項目名稱:javocsoft-toolbox,代碼行數:22,代碼來源:AdFragment.java

示例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
    }
}
 
開發者ID:tranleduy2000,項目名稱:ascii_generate,代碼行數:15,代碼來源:AdBannerActivity.java

示例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);
        }
    }
}
 
開發者ID:manuelsc,項目名稱:Lunary-Ethereum-Wallet,代碼行數:15,代碼來源:FragmentWallets.java

示例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);
    }
}
 
開發者ID:FarbodSalamat-Zadeh,項目名稱:PokedexApp,代碼行數:12,代碼來源:AdUtils.java

示例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));
    }
}
 
開發者ID:adrielcafe,項目名稱:NMSAlphabetAndroidApp,代碼行數:8,代碼來源:AdUtil.java

示例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);
}
 
開發者ID:SamukiPL,項目名稱:cykacommander,代碼行數:8,代碼來源:AndroidLauncher.java

示例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;
    }
}
 
開發者ID:jyjeanne,項目名稱:Studyandcook,代碼行數:10,代碼來源:Utils.java

示例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();
        }
    }
}
 
開發者ID:systemallica,項目名稱:ValenBisi,代碼行數:30,代碼來源:DonateFragment.java

示例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;
}
 
開發者ID:florent37,項目名稱:OCiney,代碼行數:14,代碼來源:AdsManager.java

示例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)));

}
 
開發者ID:RSenApps,項目名稱:Commandr-Android,代碼行數:30,代碼來源:VotingActivity.java

示例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));
        }
    });
}
 
開發者ID:RSenApps,項目名稱:Commandr-Android,代碼行數:40,代碼來源:MostWantedCommandsActivity.java

示例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);
}
 
開發者ID:Barqawiz,項目名稱:Android_ApplicationTemplate,代碼行數:10,代碼來源:DetailsFrag.java


注:本文中的com.google.android.gms.ads.AdView.setVisibility方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。