3

I trying to use fragments in my code..After i clicked the fragments and tries to make screen orientation i got an error like below,...

Unable to start activity ComponentInfo{com.example.frag/com.example.frag.Activity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

My Xml.

<LinearLayout android:id="@+id/linear" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" >
<ListView android:id="@+id/android:list" android:layout_height="wrap_content" android:layout_width="fill_parent"/> 
<fragment android:id="@+id/frag" android:layout_height="fill_parent" android:layout_width="fill_parent" class="com.example.frag.MyFragment"/> 

GK_
  • 1,212
  • 1
  • 12
  • 26

3 Answers3

2

I found the answer., I forgot to extend FragmentActivity istead of Activity..

It working now.

Reference:https://stackoverflow.com/a/9168223/1542636

Community
  • 1
  • 1
GK_
  • 1,212
  • 1
  • 12
  • 26
1

By the limited information you're giving, it looks like you're having the same problem addressed in this post.

Community
  • 1
  • 1
Brandon Romano
  • 1,022
  • 1
  • 13
  • 21
0

Try this:

 <fragment
    android:id="@+id/frag"
    android:name="com.example.frag.MyFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout="@layout/frag_layout" />

you must use android:name="fully qualified path". you have used class="".

SKK
  • 5,261
  • 3
  • 27
  • 39