title: One layout works but other doesnt
body: <p>everyone. I was creating a simple app for fun and came up with this problem. Basically, I checked everything and found some problem with the layouts. I am using navigation and from navigation, it takes the user to 4 different parts. Everything works except for the last part, the button is not taking me to anywhere.</p>
  
  <pre><code>import android.content.Intent;
  import android.support.v4.app.Fragment;
  
  
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v4.app.FragmentTransaction;
  import android.view.View;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.ArrayAdapter;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  
  public class MainActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
             DrawerLayout drawer = (DrawerLayout)    
  findViewById(R.id.drawer_layout);
      ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
              this, drawer, toolbar, R.string.navigation_drawer_open,   
  R.string.navigation_drawer_close);
      drawer.setDrawerListener(toggle);
      toggle.syncState();
  
      NavigationView navigationView = (NavigationView)    
  findViewById(R.id.nav_view);
      navigationView.setNavigationItemSelectedListener(this);
  
  }
  
  
  
  
  @Override
  public void onBackPressed() {
      if (getFragmentManager().getBackStackEntryCount() &gt; 0) {
          getFragmentManager().popBackStack();
      } else {
          super.onBackPressed();
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is    
  present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
  
      return super.onOptionsItemSelected(item);
  }
  
  
  
  private void displaySelectedScreen(int id)
  {
      Fragment fragment = null;
      switch(id){
          case R.id.syllabus:
              fragment = new Syllabus();
              break;
          case R.id.questionss:
              fragment = new Questions();
              break;
          case R.id.definitions:
              fragment = new Definitions();
              break;
          case R.id.contact_us:
              fragment = new Contact_Us();
              break;
      }
  
      if(fragment != null){
  
          FragmentTransaction ft =    
  getSupportFragmentManager().beginTransaction();
          ft.replace(R.id.list_content,fragment).addToBackStack("tag");
          ft.commit();
      }
  
  
  
  
  }
  
  public void chaptersdefinitions(View view) {
      Fragment newfragment = null;
      if (view == findViewById(R.id.chap1def)) {
          newfragment = new Chapter1def();
      } else if (view == findViewById(R.id.chap2def)) {
          newfragment = new Chapter2def();
      } else if (view == findViewById(R.id.chap3def)) {
          newfragment = new Chapter3def();
      } else if (view == findViewById(R.id.chap4def)) {
          newfragment = new Chapter4def();
      } else if (view == findViewById(R.id.chap5def)) {
          newfragment = new Chapter5def();
      } else if (view == findViewById(R.id.chap6def)) {
          newfragment = new Chapter6def();
      } else if (view == findViewById(R.id.chap7def)) {
          newfragment = new Chapter7def();
      } else if (view == findViewById(R.id.chap8def)) {
          newfragment = new Chapter8def();
      } else if (view == findViewById(R.id.chap9def)) {
          newfragment = new Chapter9def();
      } else if (view == findViewById(R.id.chap10def)) {
          newfragment = new Chapter10def();
  
      }  else if (view == findViewById(R.id.chapone)) {
          newfragment = new Chapter1();
      } else if (view == findViewById(R.id.chaptwo)) {
          newfragment = new Chapter2();
      } else if (view == findViewById(R.id.chapthree)) {
          newfragment = new Chapter3();
      } else if (view == findViewById(R.id.chapfour)) {
          newfragment = new Chapter4();
      } else if (view == findViewById(R.id.chapfive)) {
          newfragment = new Chapter5();
      } else if (view == findViewById(R.id.chapsix)) {
          newfragment = new Chapter6();
      } else if (view == findViewById(R.id.chapseven)) {
          newfragment = new Chapter7();
      } else if (view == findViewById(R.id.chapeight)) {
          newfragment = new Chapter8();
      } else if (view == findViewById(R.id.chapnine)) {
          newfragment = new Chapter9();
      } else if (view == findViewById(R.id.chapten)) {
          newfragment = new Chapter10();
      }
      if (newfragment != null) {
  
          FragmentTransaction ft =      
  getSupportFragmentManager().beginTransaction();
              ft.replace(R.id.list_content,      
  newfragment).addToBackStack("tag");
              ft.commit();
  
          }
      }
  
      @SuppressWarnings("StatementWithEmptyBody")
      @Override
      public boolean onNavigationItemSelected(MenuItem item) {
  
          int id = item.getItemId();
  
          DrawerLayout drawer = (DrawerLayout)               
  findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
  
          displaySelectedScreen(id);
          return true;
      }
  }
  </code></pre>
  
  <p>My content_main is:</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:layout_width="match_parent"
  android:layout_height="match_parent"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:context="com.weebly.dunyaibdp.chemistryforib.MainActivity"
  tools:showIn="@layout/app_bar_main"
  android:fitsSystemWindows="true"&gt;
  
  &lt;android.support.constraint.ConstraintLayout
      android:id="@+id/list_content"
      android:layout_width="451dp"
      android:layout_height="600dp"
      android:layout_marginBottom="8dp"
      android:layout_marginLeft="8dp"
      android:layout_marginRight="8dp"
      android:layout_marginTop="8dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintVertical_bias="0.885"
      app:layout_constraintHorizontal_bias="0.493"&gt;
      &lt;TextView
          android:id="@+id/textView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="8dp"
          android:layout_marginTop="8dp"
          android:text="Hey There!"
          android:textColor="#64dd17"
          android:textSize="50sp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintHorizontal_bias="0.502"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.237" /&gt;
  
         &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="8dp"
          android:layout_marginLeft="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginTop="8dp"
          android:text="Welcome to our Chemistry App"
          android:textColor="@android:color/holo_green_dark"
          android:textSize="25sp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.413"
          app:layout_constraintHorizontal_bias="0.483" /&gt;
  
      &lt;TextView
          android:id="@+id/textView5"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="8dp"
          android:layout_marginRight="8dp"
          android:layout_marginTop="8dp"
          android:fontFamily="monospace"
          android:text="Use navigation on the left to navigate through app"
          android:textColor="@android:color/holo_green_dark"
          android:textSize="12sp"
          android:textStyle="bold"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintHorizontal_bias="0.558"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintVertical_bias="0.53" /&gt;
  
      &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>In navigation i have syllabus class which is:</p>
  
  <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"
  
  android:orientation="vertical"&gt;
  
  &lt;ScrollView
      android:id="@+id/scrollSyllabus"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:ignore="UselessParent"&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
  
              &lt;Button
                  android:id="@+id/chapone"
                  android:layout_width="340sp"
                  android:layout_height="70sp"
                  android:layout_gravity="center"
                  android:layout_marginLeft="55sp"
                  android:layout_marginTop="50sp"
                  android:background="@drawable/roundshapebtn"
                  android:onClick="chaptersdefinitions"
                  android:text="@string/stoichometric_relations1"
                  android:textColor="#000000"
                  tools:ignore="RtlHardcoded" /&gt;
  
  
          &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Then my class for syllabus  is for layout is:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  
  
  public class Chapter1 extends Fragment {
      @Nullable
      @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup    
  container, @Nullable Bundle savedInstanceState) {
      return inflater.inflate(R.layout.chapteronesyll,container,false);
  }
  
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
      getActivity().setTitle("Stoichometric Relations");
  }
  }
  </code></pre>
  
  <p>With this class i use this layout to show:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  &lt;Button
          android:id="@+id/button2"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="one" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Now for this button i havent put any onclick so i just want this button to be displayed in screen and thats it. I tried some other layouts in my activity and some of them worked perfectly but some didnt i tried to delete and add again but this didnt work it still didnt print anything on the screen. Any help would be appreciated.</p>