title: AndroidRuntime(1130): FATAL EXCEPTION: main
body: <p>Please need help on this.When I am trying to run my app on emulator I got these error in my Logcat and my UI Crashes</p>
  
  <p><strong>logcat errors</strong> </p>
  
  <pre><code>07-04 15:54:08.453: W/dalvikvm(1130): threadid=1: thread exiting with uncaught     exception (group=0x2bd39930)
  07-04 15:54:08.870: E/AndroidRuntime(1130): FATAL EXCEPTION: main
  07-04 15:54:08.870: E/AndroidRuntime(1130): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
  {com.example.giftfinder/com.example.giftfinder.SettingActivity}: java.lang.NullPointerException
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.os.Handler.dispatchMessage(Handler.java:99)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.os.Looper.loop(Looper.java:137)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread.main(ActivityThread.java:5039)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at java.lang.reflect.Method.invoke(Method.java:511)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at dalvik.system.NativeStart.main(Native Method)
  07-04 15:54:08.870: E/AndroidRuntime(1130): Caused by: java.lang.NullPointerException
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.content.ContextWrapper.getResources(ContextWrapper.java:89
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:78)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at com.example.giftfinder.SettingActivity.&lt;init&gt;(SettingActivity.java:18)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at java.lang.Class.newInstanceImpl(Native Method)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at java.lang.Class.newInstance(Class.java:1319)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
  07-04 15:54:08.870: E/AndroidRuntime(1130):     ... 11 more
  </code></pre>
  
  <p>This my SettingActivity.java file.When I click a button in my Mainactivity file that will show this activity which actually crashes because or errors..</p>
  
  <pre><code>import android.app.Activity;
  import android.content.res.Resources;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.RadioButton;
  import android.widget.Spinner;
  import android.widget.TableRow;
  
  public class SettingActivity extends Activity {
      Spinner him;
      Spinner her;
      TableRow tr2;
      TableRow tr3;
      //ArrayAdapter&lt;String&gt; adapter;
      //private String[] mystring;
      Resources res = getResources();
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.settings);
          tr2=(TableRow)findViewById(R.id.tr2);
          tr3=(TableRow)findViewById(R.id.tr3);
          him=(Spinner)findViewById(R.id.himspinner);
          her=(Spinner)findViewById(R.id.herspinner);
  }
  public void onRadioButtonClicked(View view)
  {
      boolean checked = ((RadioButton)view).isChecked();
      switch(view.getId()){
      case R.id.him:
          if(checked){
              tr2.setVisibility(View.VISIBLE);
              him.setVisibility(View.VISIBLE);
              ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this, R.array.himentries, android.R.layout.simple_spinner_item);
              him.setAdapter(adapter);
              her.setVisibility(View.INVISIBLE);
          }
          break;
      case R.id.her:
      if(checked){
          tr2.setVisibility(View.VISIBLE);
          him.setVisibility(View.VISIBLE);
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this, R.array.herentries, android.R.layout.simple_spinner_item);
          him.setAdapter(adapter);
          her.setVisibility(View.INVISIBLE);      
      }
      break;
      case R.id.couples:
          if(checked){
          tr2.setVisibility(View.VISIBLE);    
      }
      break;
      default:
          tr2.setVisibility(View.INVISIBLE);
      }
  
  }
  
  }
  </code></pre>
  
  <p>My settings.xml file</p>
  
  <p><pre>&lt;</p>
  
  <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" 
  android:background="@drawable/background"&gt;
  
  &lt;TableLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical"&gt;
  
         &lt;TableRow 
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
               android:background="@drawable/tr1"&gt;
  
             &lt;TextView 
                 android:id="@+id/gender"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/gender"
                 android:textSize="25sp"
                 android:paddingLeft="20dp"
                 android:paddingTop="10dp"
                 android:paddingBottom="10dp"
                 /&gt;
             &lt;RadioGroup 
                 android:id="@+id/rg1"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               android:layout_marginLeft="25dp"
               android:paddingLeft="20dp"
               android:paddingTop="15dp"&gt;
             &lt;RadioButton
                 android:id="@+id/him"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/him"
                 android:textSize="15sp"
                 android:onClick="onRadioButtonClicked"/&gt;
  
             &lt;RadioButton
                 android:id="@+id/her"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/her"
                 android:textSize="15sp"
                 android:layout_marginLeft="10dp"
                 android:onClick="onRadioButtonClicked"/&gt;
  
             &lt;RadioButton
                 android:id="@+id/couples"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/couples"
                 android:textSize="15sp"
                 android:layout_marginLeft="10dp"
                 android:onClick="onRadioButtonClicked"/&gt;
  
             &lt;/RadioGroup&gt;
         &lt;/TableRow&gt;
  
  
         &lt;TableRow 
             android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:id="@+id/tr2"
             &gt;
  
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"                  
                  android:text="@string/relation"
                  android:textSize="25sp" 
                  android:paddingLeft="20dp"
                 android:paddingTop="10dp"/&gt;
  
              &lt;Spinner
                  android:id="@+id/himspinner"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="25dp"
  
                  android:prompt="@string/himprompt"
                  /&gt;
  
             &lt;Spinner 
                 android:id="@+id/herspinner"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:entries="@array/herentries"
                 android:prompt="@string/herprompt"
                 android:visibility="invisible"
                 android:layout_marginLeft="10dp"/&gt;
  
         &lt;/TableRow&gt;
         &lt;TableRow
               android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:id="@+id/tr3"
              android:visibility="invisible" &gt;
          &lt;TextView 
                 android:id="@+id/category"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/category"
                 android:textSize="25sp"
                 android:paddingLeft="20dp"
                 android:paddingTop="10dp"/&gt;
             &lt;RadioGroup 
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               android:layout_marginLeft="25dp"
               android:paddingLeft="20dp"
               android:paddingTop="15dp"&gt;
             &lt;RadioButton
                 android:id="@+id/occ"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/occ"
                 android:textSize="15sp"/&gt;
  
             &lt;RadioButton
                 android:id="@+id/feel"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/feel"
                 android:textSize="15sp"
                 android:layout_marginLeft="10dp"/&gt;
               &lt;/RadioGroup&gt; 
  
         &lt;/TableRow&gt;
  
        &lt;TableRow
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:id="@+id/tr4"
              android:visibility="invisible"&gt;
  
  
            &lt;Spinner 
                android:id="@+id/occspinner"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="20dp"
                  android:entries="@array/occentries"
                  android:prompt="@string/occprompt"/&gt;
  
  
            &lt;Spinner 
                android:id="@+id/feelspinner"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="10dp"
                  android:entries="@array/feelentries"
                  android:prompt="@string/feelprompt"/&gt;
  
         &lt;/TableRow&gt;
  
        &lt;TableRow
           android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:id="@+id/tr5" 
              android:visibility="invisible"&gt;
            &lt;TextView 
                 android:id="@+id/age"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="@string/age"
                 android:textSize="25sp" 
                 android:paddingLeft="20dp"
                 android:paddingTop="10dp"/&gt;
  
  
            &lt;Spinner 
                android:id="@+id/agespinner"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="45dp"
                  android:entries="@array/ageentries"
                  android:prompt="@string/ageprompt"/&gt;
        &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>></p>