Hello i am getting this exception while using Android 2.3.3:
android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
Exception fires in this method:
(When creating Fragment)
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (container == null) {
// We have different layouts, and in one of them this
// fragment's containing frame doesn't exist. The fragment
// may still be created from its saved state, but there is
// no reason to try to create its view hierarchy because it
// won't be displayed. Note this is not needed -- we could
// just run the code below, where we would create and return
// the view hierarchy; it would just never be used.
return null;
}
try {
//exception here
theLayout = (LinearLayout) inflater.inflate(R.layout.fragment1, container, false);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return theLayout;
}
This happens when i go to Activity and return again to FragmentActivity and switch tabs.
What i should do for this one ?
Thanks.
I got the same error (but I’m using MonoDroid and C#). In my case, I tried to inflate a layout that contains a
<fragment>tag, but the OS (Android 2.3.3) doesn’t know about fragments.The solution for me was to use the Android Support Package v4 (android-support-v4.jar, can be found in
<android-sdk>/extras/android/support/v4folder). I then created the fragment using the SupportingFragmentManager.A description for MonoDroid with example code (that can be easily converted to Java) can be found here: http://docs.xamarin.com/android/tutorials/Fragments/Part_4_-_Providing_Backwards_Compatibility_with_the_Android_Support_Package