So, with new google-admob SDK for android correct way to place banner ad in the layout is for example like this :
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_gravity="bottom"
android:layout_height="wrap_content"
ads:adUnitId="some id"
ads:adSize="BANNER"/>
My problem is that I have multiple banner ads throughout various activities and when I for some reason want to change adUnitId I do not want to chase this snippet of code through all my xml layout files. I want to have one place where I define my adUnitId that all banner ads in the app uses. That was possible in the previous admob-only SDK, by setting meta data in manifest file. And I do not want to layout AdView in Java code, want it to be in xml if possible with the new SDK.
I tried with something like this :
ads:adUnitId="@string/admob_id"
but it just see it as a string as I can see, not following through to the actual string defined in the strings.xml. Any ideas?
With the newest admob update, I was forced to do most of my AdMob activities in my Java classes. This is how I made it work (with a centralized ID):
Edit: I keep the
LinearLayoutdefinition in the xml files so the positioning is all done throughout the xml: