title: Can't Open Fragment when clicked button
body: <p>I have created 2 fragment and their layout,
  when i click button on profile fragment it should open flat layout, but
  it force stop application and its not opening the second fragment,
  i have included fragment code and its layout code..</p>
  
  <blockquote>
    <p>profilefragment.java</p>
  </blockquote>
  
  <pre><code>public class ProfileFragment extends Fragment {
  View rootView;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      rootView = inflater.inflate(R.layout.profile, container, false);
  
      Button button = (Button) rootView.findViewById(R.id.button);
      button.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              onButtonClicked(v);
          }
      });
      return rootView;
  }
  public void onButtonClicked(View view)
  {
      //do your stuff here..
      final FragmentTransaction ft = getFragmentManager().beginTransaction();
      ft.replace(R.id.button, new flatview(), "NewFragmentTag");
      ft.commit();
  }
  </code></pre>
  
  <blockquote>
    <p>profile.xml</p>
  </blockquote>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="${packageName}.${activityClass}"
  android:id="@+id/semester"&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="New Button"
      android:id="@+id/button"
      android:layout_centerVertical="true"
      android:layout_centerHorizontal="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <blockquote>
    <p>flatview.java</p>
  </blockquote>
  
  <pre><code>public class flatview extends Fragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      return inflater.inflate(R.layout.flat, container, false);
  }
  </code></pre>
  
  <blockquote>
    <p>flat.xml</p>
  </blockquote>
  
  <pre><code>&lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:text="second fragement"
      android:id="@+id/textView3"
      android:layout_gravity="center_horizontal" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>logcat</p>
  
  <pre><code>06-19 07:57:56.945  26457-26457/com.idealdeveloper.saltechnical E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.idealdeveloper.saltechnical, PID: 26457
  java.lang.ClassCastException: android.widget.Button cannot be cast to android.view.ViewGroup
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:917)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
          at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:135)
          at android.app.ActivityThread.main(ActivityThread.java:5221)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  </code></pre>