2

Hey i recently add a ads banner to my app

and after i added it all works fine... Until I rotate the phone and then the app crash

I added the following code to my original app code: In my home fragment ,

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;

in the 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" />

should I call on destroy and do something?

Thanks for the help

4

1 回答 1

0

Problem solved.

The problem was that I forgot to put the xml code in the layout-land xml too.

Thanks :)

于 2013-04-27T06:56:43.120 回答