首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Admob Android Eclipse加载AdView

问使用Admob Android Eclipse加载AdView
EN

Stack Overflow用户
提问于 2014-11-28 03:08:43
回答 1查看 519关注 0票数 0

如何在Android (Eclipse)中加载AdView。我试了所有的方法都没有结果!我在项目中添加了google play服务库,我试图遵循一些手册,文档,但没有显示我的广告。这是我的代码!谢谢

清单

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.carle.segretihs"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >



    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".HomeActivity"
        android:label="@string/title_activity_home"
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
    </activity>


    <activity
        android:name=".SecretsActivity"
        android:label="@string/title_activity_secrets" 
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" >
    </activity>
     <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

 </manifest>

SecretsActivity.java

代码语言:javascript
复制
public class SecretsActivity extends FragmentActivity  {
ImageView a,b,c,d,e,f,g,h,i,l;
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_secrets);


    int eroe=getIntent().getExtras().getInt("eroe");

    a=(ImageView)findViewById(R.id.imageView1);
    b=(ImageView)findViewById(R.id.imageView2);
    c=(ImageView)findViewById(R.id.imageView3);
    d=(ImageView)findViewById(R.id.imageView4);
    e=(ImageView)findViewById(R.id.imageView5);
    f=(ImageView)findViewById(R.id.imageView6);
    g=(ImageView)findViewById(R.id.imageView7);
    h=(ImageView)findViewById(R.id.imageView8);
    i=(ImageView)findViewById(R.id.imageView9);
    l=(ImageView)findViewById(R.id.imageView10);

    AdView adView = (AdView)this.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("TEST_DEVICE_ID")
    .build();
    adView.loadAd(adRequest);

    //other code


}
}

activity_secrets.xml

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/hearthtexture"
tools:context="${relativePackage}.${activityClass}"
android:id="@+id/rootViewGroup"
 >

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-2830551115211229/5191182799" >
</com.google.android.gms.ads.AdView>

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/adView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />

        <ImageView
            android:id="@+id/imageView8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/imageView9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/imageView10"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</ScrollView>

</RelativeLayout>
EN

回答 1

Stack Overflow用户

发布于 2014-11-28 23:55:25

试着把com.google.android.gms.ads.AdView放在滚动视图下面。如果滚动视图比屏幕大,则广告视图将隐藏在它的下面。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27177446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档