title: Android how do i acces elements in a fragment?
body: <p>I've got an activity that loads 2 different fragments and switches between them when needed. The problem is I cant acces any elements that are in the fragments. I need to be able to set the typeface and text in the toolbar as well as be able to set the checkboxes.</p>
  
  <p>fragment XML:</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"
  android:weightSum="3"&gt;
  
  &lt;include
      layout="@layout/toolbar_main"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/&gt;
  
  &lt;CheckBox
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="15dp"
      android:id="@+id/cycle_button"
      android:button="@null"
      android:background="@drawable/cycle"
      android:layout_weight="1"
      android:layout_gravity="center_vertical" /&gt;
  
  &lt;CheckBox
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="15dp"
      android:id="@+id/walk_button"
      android:button="@null"
      android:background="@drawable/walk"
      android:layout_weight="1"
      android:layout_gravity="center_vertical" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>java file:</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowTitleEnabled(false);
  
      TextView appTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
      appTitle.setText("title");
  
      CheckBox cycle = (CheckBox) getView().findViewById(R.id.cycle_button);
      CheckBox walk = (CheckBox) findViewById(R.id.walk_button);
  }
  </code></pre>
  
  <p>the findViewById doesn't work on the fragment and it just keeps returning null.</p>