title: null pointer exception android studio
body: <p>this is what I am trying to do. First, get the current text size from a radio button, and then set the text size of a text view to that value. however, when I try I always get a "null pointer exception" error. i have researched this and not found an answer that fixes my problem. The radio button is rb1 and the textview is sampleText.</p>
  
  <pre><code>public class Settings extends Activity {
  
  RadioButton rb1;
  RadioButton rb2;
  RadioButton rb3;
  RadioGroup ans;
  TextView sampleT;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.settings);
  
      ans= (RadioGroup) findViewById(R.id.answers);
      rb1= (RadioButton) findViewById(R.id.answer1);
      rb2= (RadioButton) findViewById(R.id.answer2);
      rb3= (RadioButton) findViewById(R.id.answer3);
      sampleT= (TextView) findViewById(R.id.sampleText);
  
       float default_font_size=rb1.getTextSize(); //this is the line with error
       sampleT.setTextSize(default_font_size);
  
      }
  }
  </code></pre>
  
  <p><strong>Logcat</strong></p>
  
  <pre><code>06-11 14:37:31.809  15625-15625/com.nick.simplequiz            E/AndroidRuntime: FATAL EXCEPTION: main
          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nick.simplequiz/com.nick.simplequiz.Settings}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2351)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
          at android.app.ActivityThread.access$600(ActivityThread.java:151)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:155)
          at android.app.ActivityThread.main(ActivityThread.java:5454)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:511)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
          at dalvik.system.NativeStart.main(Native Method)
          Caused by: java.lang.NullPointerException
          at com.nick.simplequiz.Settings.onCreate(Settings.java:32)
          at android.app.Activity.performCreate(Activity.java:5066)
  </code></pre>
  
  <p>settings.xml:</p>
  
  <pre><code>&lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Answer Choice Text Size"
          android:id="@+id/sampleText"
          android:layout_gravity="left|center_vertical"
          android:textStyle="bold"
          android:textSize="25dp"/&gt;
  
      &lt;SeekBar
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:id="@+id/seekBar"
          android:layout_gravity="center"
          android:progress="50"/&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>