Runtime error inflating fragment
<p><strong>Error:</strong> java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.todolist/com.example.todolist.ToDoListActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment</p>

<p>I know this question has been asked before but i have searched through them and could not find a solution. I get this error a few seconds after the app is launched without touching anything, the fragments do not load and then it crashes.</p>

<p>I have one FragmentActivity class with two Fragments in it(ListFragment and EditText).My min sdk support is 7 so i am using support library imports.</p>

<p><strong>This is the code for the FragmentActivity:</strong></p>

<pre><code>public class ToDoListActivity extends FragmentActivity
        implements NewItemFragment.OnNewItemAddedListener{

private ArrayList&lt;String&gt; todoItems;
private ArrayAdapter&lt;String&gt; aa;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_to_do_list);

    FragmentManager fm = getSupportFragmentManager();
    ToDoListFragment toDoListFragment = (ToDoListFragment)
            fm.findFragmentById(R.id.ToDoListFragment);




    aa = new ArrayAdapter&lt;String&gt;(this,
                    android.R.layout.simple_list_item_1,
                        todoItems);

    toDoListFragment.setListAdapter(aa);


}

public void onNewItemAdded(String newItem){
    todoItems.add(newItem);
    aa.notifyDataSetChanged();

}
</code></pre>

<p><strong>This is the layout for the FragmentActivity:</strong></p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" &gt;

&lt;fragment
    android:id="@+id/NewItemFragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:name="com.example.todolist.NewItemFragment"/&gt;

&lt;fragment
    android:id="@+id/ToDoListFragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:name="com.example.todolist.ToDoListFragment" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p><strong>This is the EditText Fragment code:</strong></p>

<pre><code>public class NewItemFragment extends Fragment {

private OnNewItemAddedListener onNewItemAddedListener;

public interface OnNewItemAddedListener {
    public void onNewItemAdded(String newItem);
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);

try {
onNewItemAddedListener = (OnNewItemAddedListener)activity;
}catch (ClassCastException e) {
    throw new ClassCastException(activity.toString() +
            "must implement OnNewItemAddedListener");
    }
}

public View OnCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState){

    View view = inflater.inflate(R.layout.new_item_fragment, container
            , false);

    final EditText myEditText = (EditText)view.findViewById(R.id.myEditText);

    myEditText.setOnKeyListener(new View.OnKeyListener() {

        ...
    });
    return view;
}
</code></pre>

<p>}</p>

<p><strong>This is the EditText Fragment Layout:</strong>
    </p>

<pre><code>&lt;EditText xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/addItemHint"
    android:contentDescription="@string/addItemContentDescription" /&gt;
</code></pre>

<p><strong>My ListFragment Class uses the default layout so i only created a .java file with the class
declaration(the class name is the same as the name written in the fragment activity XML)</strong></p>

<p><strong>This the remaining of the LogCat:</strong></p>

<pre><code>02-17 17:33:25.135: E/AndroidRuntime(23262):    at      android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.os.Looper.loop(Looper.java:123)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.ActivityThread.main(ActivityThread.java:3691)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at java.lang.reflect.Method.invokeNative(Native Method)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at java.lang.reflect.Method.invoke(Method.java:507)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at dalvik.system.NativeStart.main(Native Method)
02-17 17:33:25.135: E/AndroidRuntime(23262): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.Activity.setContentView(Activity.java:1663)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at com.example.todolist.ToDoListActivity.onCreate(ToDoListActivity.java:18)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
02-17 17:33:25.135: E/AndroidRuntime(23262):    ... 11 more
02-17 17:33:25.135: E/AndroidRuntime(23262): Caused by: java.lang.IllegalStateException: Fragment com.example.todolist.NewItemFragment did not create a view.
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:303)
02-17 17:33:25.135: E/AndroidRuntime(23262):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
</code></pre>
