android - Admob ads for multiple activites via XML -


hello i'm new admob have added admob main activity xml via below code provided google, thing ad contains on main activity.. planned paste same code other activities well.. right method ? or there way xml not java..

<com.google.android.gms.ads.adview     android:id="@+id/adview"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerhorizontal="true"     android:layout_alignparentbottom="true"     ads:adsize="banner"     ads:adunitid="@string/banner_ad_unit_id"> </com.google.android.gms.ads.adview> 

thanks

you can create separate layout called ad_view.xml or , include in other layouts include tag, this:

ad_view.xml

<com.google.android.gms.ads.adview     android:id="@+id/adview"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerhorizontal="true"     android:layout_alignparentbottom="true"     ads:adsize="banner"     ads:adunitid="@string/banner_ad_unit_id"> </com.google.android.gms.ads.adview> 

your other layouts

<include         layout="@layout/ad_view"         android:id="@+id/ad_view"/> 

note in include can override multiple properties of layout usefull. hope helps out, luck.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -