Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 在actionbarsherlock上方获取admob大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在同一个 Android应用程序中使用AdMob和ActionBarSherlock,但我没有设法将AdMob放在我的屏幕顶部(在Sherlock ActionBar之上).

有人有类似的问题吗?有谁知道一些解决方法

谢谢.

我的总体布局:

<LinearLayout xmlns:android="http://scheR_543_11845@as.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" > 
<include layout="@layout/admob"/> 
<TabHost
 xmlns:android="http://scheR_543_11845@as.android.com/apk/res/android"
 android:id="@android:id/tabhost"
 android:layout_width="match_parent"
 android:layout_height="match_parent">
 <LinearLayout.....

我的adob布局:

<?xml version="1.0" encoding="utf-8"?>
<com.google.ads.AdView xmlns:android="http://scheR_543_11845@as.android.com/apk/res/android"
                    xmlns:ads="http://scheR_543_11845@as.android.com/apk/lib/com.google.ads"
                    android:id="@+id/adView"
                    android:layout_height="wrap_content"
                    ads:adUnitId="123456"
                    ads:adSize="BAnnER" 
                    android:layout_width="match_parent"/>

解决方法

我正在使用ActionBarSherlock作为包装器,以下内容将广告放在操作栏上方:

private ActionBarSherlock sherlock = ActionBarSherlock.wrap(this);

@Override
public void onCreate(Bundle savedInstanceStatE)
{
    /* ... set up layout here ... */


    adView = new AdView(this,AdSize.bAnnER,"deadbeefmeat");

    ViewParent parentView = appView.getParent();
    do
    {
        parentView = parentView.getParent();
    } while(!(parentView instanceof LinearLayout));

    ((LinearLayout)parentView).addView(adView,0);

    Adrequest adrequest = new Adrequest();
    adrequest.addTestDevice(Adrequest.test_EMULATOR);
    adView.loadAd(adrequest);
}

// All setContentView methods are overridden because ActionBarSherlock has to modify the view
@Override
public void setContentView(int layoutResID)
{
    // Don't call super!
    sherlock.setContentView(layoutResID);
}

@Override
public void setContentView(View view)
{
    // Don't call super!
    sherlock.setContentView(view);
}

@Override
public void setContentView(View view,LayoutParams params)
{
    // Don't call super!
    sherlock.setContentView(view,params);
}

大佬总结

以上是大佬教程为你收集整理的android – 在actionbarsherlock上方获取admob全部内容,希望文章能够帮你解决android – 在actionbarsherlock上方获取admob所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。