문제

I am building an Android App for a company that contains 'sponsors' (ads in form of banners).Does anyone help me with the sample code and procedure for implementing ads in my Apps' activities?

도움이 되었습니까?

해결책

use this code

AdView adview = (AdView)findViewById(R.id.add_view);      
AdRequest re = new AdRequest();               
adview.loadAd(re);  

and xml

<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/res/com.flash.light"
    android:id="@+id/add_view"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="a14e843bea82be1"/>      

values folder attr.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.google.ads.AdView">
  <attr name="adSize">
      <enum name="BANNER" value="1"/>
      <enum name="IAB_MRECT" value="2"/>
      <enum name="IAB_BANNER" value="3"/>
      <enum name="IAB_LEADERBOARD" value="4"/>
  </attr>
  <attr name="adUnitId" format="string"/>

add jar file to u r project.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top