[英]Android app crash when rotating using AdMob
嘿,我最近在我的应用中添加了广告横幅
在我添加完之后一切正常...直到我旋转手机,然后应用崩溃
我在原始应用程序代码中添加了以下代码:在我的家庭片段中,
On create view:
...
mAdStatus = (TextView) v.findViewById(R.id.status);
mAdView = (AdView) v.findViewById(R.id.ad);
mAdView.setAdListener(new MyAdListener(mAdStatus));
AdRequest adRequest = new AdRequest();
adRequest.addKeyword("sporting goods");
mAdView.loadAd(adRequest);
return v;
在xml中:
<LinearLayout
android:id="@+id/ad_catalog_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:text="" />
<com.google.ads.AdView xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="@string/admob_id" />
我应该呼吁销毁并采取措施吗?
谢谢您的帮助
问题解决了。
问题是我也忘记了将XML代码也放在版图设计xml中。
谢谢 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.