Ad Banner Implementation in Activities of Android Application
-
09-02-2021 - |
Вопрос
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.
Не связан с StackOverflow