Reputation: 2040
I am able to ad the ads into my apps main activity. But I can not figure out how to make it display across all three activities i have in my app.
Upvotes: 0
Views: 479
Reputation:
import com.google.ads.*;
public class testActivity extends Activity {
private static final String MY_AD_UNIT_ID = "yourId";
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
// Create the adView
adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout layout = super.root; // this is the only change
layout.addView(adView);
adView.loadAd(new AdRequest());
Xml File:
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:backgroundColor="#000000"
xmlns:primaryTextColor="#ffffff"
xmlns:secondaryTextColor="#cccccc"
Upvotes: 2
Reputation: 9915
Have you included the tag in all of your layouts.
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:backgroundColor="#000000"
xmlns:primaryTextColor="#ffffff"
xmlns:secondaryTextColor="#cccccc"
/>
Upvotes: 0