내 프로그램에 admob을 추가하고 싶지만 항상 하나 대신 두 개의 광고가 표시됩니다. 나는 광고를 통해 내 활동의 중심에 서기를 원한다. 이 두 광고는 상단에 붙어 어떻게 그 중 하나를 제거 할 수 있습니까? 여기 admob 선형 레이아웃 더블 광고?
은 XML입니다 :<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:gravity="top"
tools:context=".MainActivity" >
<ImageButton
android:id="@+id/btnSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="25dp"
android:background="@null"
android:contentDescription="@null"
android:src="@drawable/btn_switch_on" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_centerHorizontal="true"
android:text="@string/Develop"
android:textColor="#C0C0C0"
android:textSize="15sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="5dp"
android:text="@string/soheilen"
android:textColor="#C0C0C0"
android:textSize="18sp" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="@null"
android:contentDescription="@null"
android:minHeight="64dp"
android:minWidth="64dp"
android:src="@drawable/more" />
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/mute"
android:textOff="@string/mute"
android:textOn="@string/mute" />
<LinearLayout
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_width="fill_parent"
android:id="@+id/mainline"
android:gravity="top"
>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="aXXXXXXXXXXb"
ads:loadAdOnCreate="true"
android:gravity="top" >
</com.google.ads.AdView>
</LinearLayout>
</RelativeLayout>
하고 여기에 주요 자바 내 코드 : 나는 상대 레이아웃하지만이 제대로 작동하지 않을에 같은 다른 설정을 시도
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest();
adView = new AdView(this, AdSize.BANNER,"xxxxxxxxxxxx");
LinearLayout layout = (LinearLayout) findViewById(R.id.mainline);
layout.addView(adView);
adView.loadAd(adRequest);
!
xml과 다른 프로그래밍 방식으로 두 개의 AdView를 추가하는 이유 중 하나를 삭제하십시오. – Oam
@Oam im to new android 어느 것이 제거하는 것이 더 낫습니다. 그리고 xml에서 코드를 제거하는 방법은? – Soheyl
위의 코드에서 3 번째 줄과 5 번째 줄을 제거하고 확인하십시오. – Oam