以下代码来自示例应用程序,效果很好,我发现即使删除 AdView adView = (AdView)this.findViewById(R.id.adViewabout) 和 loadAd(new AdRequest()),Admob 仍然可以显示。
为什么?谢谢!
public class AboutActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
TextView mLink = (TextView) findViewById(R.id.tvMyLink);
mLink.setMovementMethod(LinkMovementMethod.getInstance());
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adViewabout);
adView.loadAd(new AdRequest());
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="3dip"
android:background="@drawable/border_ui"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/appversion"
android:paddingLeft="7dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="7dip"
android:text="V1.04" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/myabout"
android:layout_marginTop="8dip"
android:paddingLeft="7dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvMyLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dip"
android:paddingLeft="7dip"
android:text="@string/mylink" />
<com.google.ads.AdView
android:id="@+id/adViewabout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="a151bc26cd3bc22"
ads:loadAdOnCreate="true" />
<TextView
android:id="@+id/tvOnlyTake"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="" />
<Button
android:id="@+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="@style/myTextAppearance"
android:text="@string/myreturn" />
</LinearLayout>