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


Java AdView類代碼示例

本文整理匯總了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;

}
 
開發者ID:changja88,項目名稱:Udacity_Gradle,代碼行數:17,代碼來源:MainActivityFragment.java

示例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);
}
 
開發者ID:tmurakam,項目名稱:presentationtimer-android,代碼行數:22,代碼來源:PrefActivity.java

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

示例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);
        }
    });
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:22,代碼來源:Ads.java

示例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;
}
 
開發者ID:vixir,項目名稱:Perfect-Day,代碼行數:17,代碼來源:MoreInfoFragment.java

示例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);
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:26,代碼來源:SqlTabDatasActivity.java

示例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);
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:18,代碼來源:DbTablesActivity.java

示例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);
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:24,代碼來源:ActivityMain.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:20,代碼來源:quiz15Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:18,代碼來源:quiz5Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:18,代碼來源:quiz9Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:18,代碼來源:quiz3Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:20,代碼來源:quiz13Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:20,代碼來源:quiz10Fragment.java

示例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;
}
 
開發者ID:akarshsingh9,項目名稱:CodeInPython,代碼行數:18,代碼來源:quiz2Fragment.java


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