title: How to put FloatingActionButton to Fragment?
body: <p>How can I put my <code>fab</code> on my fragment? help please I'm getting errors such as.</p>
  
  <blockquote>
    <p>android.view.InflateException: Binary XML file line #13: Error inflating class fragment</p>
  </blockquote>
  
  <p>in my fragment acticity. Well here are my codes.</p>
  
  <p>well the problem is in the    <code>getActivity().setContentView(R.layout.activity_ownerhome);</code></p>
  
  <pre><code>#ownerhome.java
  
  public class ownerhome extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_ownerhome);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      }
  
  }
  </code></pre>
  
  <h1>ownerhomeFragment.java</h1>
  
  <pre><code> @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View v =  inflater.inflate(R.layout.fragment_owner, container, false);
  
  
      ImageLoader.getInstance().init(UILConfig.config(getActivity()));
      lvCars = (ListView) v.findViewById(R.id.lvOnwer);
  
      pref = getActivity().getSharedPreferences("Login.conf", Context.MODE_PRIVATE);
      Log.d(TAG, pref.getString("username", ""));
      Log.d(TAG, pref.getString("password", ""));
  
  
      PostResponseAsyncTask taskRead = new PostResponseAsyncTask(getActivity(), this);
      tvUser = (TextView) v.findViewById(R.id.tvUser);
      tvUser.setText("Hello! "+pref.getString("username", ""));
  
      taskRead.execute("http://carkila.esy.es/user.php?owner="+pref.getString("username", ""));
  
      FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent in = new Intent(getActivity(), InsertActivity.class);
              startActivity(in);
          }
      });
      registerForContextMenu(lvCars);
      return v;
  }
  </code></pre>
  
  <h1>content_ownerhome.xml</h1>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.example.kun.carkila.ownerhome"
  tools:showIn="@layout/activity_ownerhome"&gt;
  
  &lt;fragment
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:name="com.example.kun.carkila.ownerFragment"
  android:id="@+id/ownerhomeFragment"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <h1>activity_ownerhome.xml</h1>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;    &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fitsSystemWindows="true"
  tools:context="com.example.kun.carkila.ownerhome"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;include layout="@layout/content_ownerhome" /&gt;
  
  &lt;android.support.design.widget.FloatingActionButton
      android:id="@+id/fab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|end"
      android:layout_margin="@dimen/fab_margin"
      android:src="@drawable/plus" /&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <h1>fragmentOwnerHome.xml</h1>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.example.kun.carkila.ownerhome"
  tools:showIn="@layout/activity_ownerhome"&gt;
  
  
  &lt;ListView
      android:layout_width="match_parent"
      android:layout_height="450sp"
      android:id="@+id/lvOnwer"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignParentBottom="true" /&gt;
  
  &lt;TextView
      android:text="TextView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_marginTop="24dp"
      android:textSize="30sp"
      android:textColor="@color/colorPrimaryDark"
      android:id="@+id/tvUser" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>STACK TRACE</p>
  </blockquote>
  
  <pre><code>FATAL EXCEPTION: main
  Process: com.example.kun.carkila, PID: 9267
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kun.carkila/com.example.kun.carkila.ownerhome}: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  at android.app.ActivityThread.access$800(ActivityThread.java:135)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5021)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class fragment
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
  at com.example.kun.carkila.ownerFragment.onCreateView(ownerFragment.java:127)
  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1036)
  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1230)
  at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1332)
  at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2288)
  at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
  at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
  at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:31)
  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:79)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
  at com.example.kun.carkila.ownerhome.onCreate(ownerhome.java:12)
  at android.app.Activity.performCreate(Activity.java:5231)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
  at android.os.Handler.dispatchMessage(Handler.java:102) 
  at android.os.Looper.loop(Looper.java:136) 
  at android.app.ActivityThread.main(ActivityThread.java:5021) 
  at java.lang.reflect.Method.invokeNative(Native Method) 
  at java.lang.reflect.Method.invoke(Method.java:515) 
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:827) 
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643) 
  at dalvik.system.NativeStart.main(Native Method) 
  Caused by: java.lang.IllegalArgumentException: Binary XML file line #12: Duplicate id 0x7f0e00aa, tag null, or parent id 0xffffffff with another fragment for com.example.kun.carkila.ownerFragment
  at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2293)
  at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
  at android.support.v4.app.FragmentActivity
  </code></pre>