title: Fragment at android.support.v7
body: <p>I am new to android, I tried to create a fragment in android support v7 library
  and when I wanted to make an object from fragment class and new it with my fragment java it occurred with an error that could not compile type.</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private TextView mTextMessage;
  
      private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
              = new BottomNavigationView.OnNavigationItemSelectedListener() {
  
          @Override
          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
              switch (item.getItemId()) {
                  case R.id.navigation_home:
                      mTextMessage.setText(R.string.title_home);
                      return true;
                  case R.id.navigation_dashboard:
                      mTextMessage.setText(R.string.title_dashboard);
                      return true;
                  case R.id.navigation_notifications:
                      mTextMessage.setText(R.string.title_notifications);
                      return true;
              }
              return false;
          }
      };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mTextMessage = (TextView) findViewById(R.id.message);
          BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
          navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
      }
  
      public boolean test(){
          Fragment fr =  new navigation_page1();
          FragmentManager fm = getFragmentManager();
          FragmentTransaction ft = fm.beginTransaction();
          ft.replace(R.id.fragment_page1,fr);
      }
  
  }
  </code></pre>
  
  <p>error is in this line  </p>
  
  <p><code>Fragment fr =  new navigation_page1();</code></p>
  
  <p>and <code>navigation_page1</code> is my fragment java code that has been initialized in my main layout with fragment tag.</p>
  
  <p>my main_xml code :</p>
  
  <pre><code>        &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
          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:id="@+id/container"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          tools:context=".MainActivity"&gt;
      &lt;fragment
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:name="com.example.aqamamad.myapplication.navigation_page1"
              android:id="@+id/fragment_page1"
  
      &gt;&lt;/fragment&gt;
      &lt;android.support.design.widget.BottomNavigationView
              android:id="@+id/navigation"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginEnd="0dp"
              android:layout_marginStart="0dp"
              android:background="?android:attr/windowBackground"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintLeft_toLeftOf="parent"
              app:layout_constraintRight_toRightOf="parent"
              app:menu="@menu/navigation"/&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>my navigation_page1 code :</p>
  
  <pre><code>   public class navigation_page1 extends Fragment {
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // Inflate the layout for this fragment
      return inflater.inflate(R.layout.fragment_navigation_page1, container, false);
  }}
  </code></pre>