共同片段被用在2活動的使用FragmentActivity拋出InflateException
public class Ads extends Fragment {
private View rootView ;
private MoPubView adView ;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.ads, container, true) ;
adView = (MoPubView) rootView.findViewById(R.id.adView) ;
adView.setAdUnitId(LogoQuizUtil.MOPUB_AD_UNIT);
adView.loadAd();
return rootView;
}
}
片段佈局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ad_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom" >
<com.mopub.mobileads.MoPubView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:gravity="bottom" />
</LinearLayout>
其他佈局,其中包括我這個片段
我得到一個不明白第一次調用setContentView(R.layout.ads)時發生異常,第二次調用時調用fragementactivity(Ads)我在setContentView(R.id.ads)處得到一個異常。
例外,我得到的是
08-07 09:38:30.359: W/System.err(975): java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.SecondActivity}: android.view.InflateException: Binary XML file line #263: Error inflating class fragment
顯示您的片段的代碼。 – Barak 2012-08-07 04:37:08
其上廣告延伸FragmentActivity – Siddharth 2012-08-07 04:42:47
然後你需要研究片段。這是**不是**一個片段。這是支持庫中的一個類,用於創建可以使用片段的活動。片段將擴展片段類。 – Barak 2012-08-07 04:53:20