2012-09-04 2 views
4

동일한 Android appplication에서 AdMob과 ActionBarSherlock을 사용하고 싶지만 AdMob을 내 화면 상단에 올려 놓지 마십시오 (Sherlock ActionBar 위).actionbarsherlock 위의 admob 받기

누구나 비슷한 문제가 있습니까? 누구나 해결 방법에 대해 알고 있습니까?

감사합니다.

내 일반적인 레이아웃 :

<LinearLayout xmlns:android="http://schemas.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://schemas.android.com/apk/res/android" 
android:id="@android:id/tabhost" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<LinearLayout..... 

내 몹 레이아웃 :

<?xml version="1.0" encoding="utf-8"?> 
<com.google.ads.AdView xmlns:android="http://schemas.android.com/apk/res/android" 
        xmlns:ads="http://schemas.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"/> 

답변

1

내가 래퍼로서 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); 
} 
+0

을 나는 안드로이드 ActionBar에서 빌드와 함께 작동하는 방법을 찾지 못했습니다. 방법을 알고 있니? 이것은 안드로이드 ActionBar에 질문 할 수 있습니다 : http://stackoverflow.com/questions/17258323/how-to-place-admob-at-the-top-of-the-screen-above-android-actionbar –