title: RadioButton setChecked NullPointerException
body: <p>I  don't get this to work and I don't see why.</p>
  
  <blockquote>
  <pre><code> Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RadioButton.setChecked(boolean)' on a null object reference
          at eu.twenty1media.snakeplus.fragment.MainFragment.onCreateView(MainFragment.java:48)
  </code></pre>
  </blockquote>
  
  <pre><code>    String lastlevel = msettings.getLevel();
      Log.d("MainFragment.java", "Last level from Database: radio"+lastlevel);
  
      RadioGroup rLevelGroup = (RadioGroup) getActivity().findViewById(R.id.radioLevel);
      int resourceId = this.getResources().getIdentifier("radio"+lastlevel, "id", getActivity().getPackageName());
  
      //rLevelGroup.check(R.id.radioextreme); //Nullpointer!
  
      //RadioButton levelbtn = (RadioButton) getActivity().findViewById(R.id.radioextreme); //NULLPOINTER
      //levelbtn.setChecked(true);
  </code></pre>
  
  <p>I tried both methods at the bottom, but none of them seems to work, I always get a NPE. I tried using the resourceId String but as you can see a normal resource id aswell.</p>
  
  <pre><code>    &lt;RadioGroup
      android:id="@+id/radioLevel"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:orientation="horizontal"
      android:layout_marginBottom="16dp"
      android:gravity="center"&gt;
      &lt;RadioButton
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:id="@+id/radionormal"
          android:text="@string/level_normal"
          android:background="@drawable/radiolevel"
          android:button="@android:color/transparent"
          android:paddingLeft="8dp"
          android:paddingRight="8dp"
          android:paddingTop="4dp"
          android:paddingBottom="4dp"
          android:layout_marginRight="2dp"
          android:layout_marginLeft="2dp"
  
          android:gravity="center"
          android:textColor="@color/orange_1"
          android:textStyle="bold"
          /&gt;
      &lt;RadioButton
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:id="@+id/radiohard"
          android:background="@drawable/radiolevel"
          android:button="@android:color/transparent"
          android:text="@string/level_hard"
          android:paddingLeft="8dp"
          android:paddingRight="8dp"
          android:paddingTop="4dp"
          android:paddingBottom="4dp"
          android:layout_marginRight="2dp"
          android:layout_marginLeft="2dp"
          android:gravity="center"
          android:textColor="@color/orange_1"
          android:textStyle="bold"
          /&gt;
      &lt;RadioButton
          android:layout_width="90dp"
          android:layout_height="wrap_content"
          android:id="@+id/radioextreme"
          android:background="@drawable/radiolevel"
          android:button="@android:color/transparent"
          android:text="@string/level_extreme"
          android:paddingLeft="8dp"
          android:paddingRight="8dp"
          android:paddingTop="4dp"
          android:paddingBottom="4dp"
          android:layout_marginRight="2dp"
          android:layout_marginLeft="2dp"
          android:gravity="center"
          android:textColor="@color/orange_1"
          android:textStyle="bold"
          /&gt;
      &lt;/RadioGroup&gt;
  </code></pre>
  
  <p>Thanks for the help. </p>
  
  <p>EDIT1: With commenting the Lines below i don't get a Nullpointer Exception.</p>