title: NullPointerException with string-array in Spinner
body: <p>First app and so really new at android (played around about a year ago but nothing came of it), decent at programming. Wanting to make sure app renders on a phone, no functionality atm. Compiles fine, no problems there. Push it to my phone and "Unfortunately, Splitr has stopped".</p>
  
  <p>Edit - added to the MainActivity.java, edits have * before and after (not in actual code) but now it flags </p>
  
  <pre><code>adapter.setDropDownViewResource(android.R.layout.activity_main);
  // Apply the adapter to the spinner
  spinnerSplit.setAdapter(adapter);
  </code></pre>
  
  <p>saying Error:(18, 36) identifier expected</p>
  
  <p>setDropDownViewResource, activity_main and setAdapter all in red</p>
  
  <p>Android Studio<br>
  Moto G - CM11 4.4.4</p>
  
  <p>Here is the code, let me know if I missed anything out.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.hydr0dr4gon.splitrv2;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  *import android.widget.ArrayAdapter;
  import android.widget.Spinner;*
  
  
  public class MainActivity extends Activity {
  
      *Spinner spinnerSplit = (Spinner) findViewById(R.id.spinner);
  // Create an ArrayAdapter using the string array and a default spinner layout
  ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
          R.array.arraySplitr, android.R.layout.simple_spinner_item);
  // Specify the layout to use when the list of choices appears
  adapter.setDropDownViewResource(android.R.layout.activity_main);
  // Apply the adapter to the spinner
  spinnerSplit.setAdapter(adapter);*
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  
  @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();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
   }
  }
  </code></pre>
  
  <p>SplitrDialogFragment.java</p>
  
  <pre><code>package com.hydr0dr4gon.splitrv2;
  
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.app.DialogFragment;
  import android.content.DialogInterface;
  import android.os.Bundle;
  
  public class SplitrDialogFragment extends DialogFragment {
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      // Use the Builder class for convenient dialog construction
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
  
      builder.setMessage(R.string.dialog_split_pay)
              .setNegativeButton(R.string.OK, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                      // User cancelled the dialog
                  }
              });
  
      // Create the AlertDialog object and return it
      return builder.create();
   }
  }
  </code></pre>
  
  <p>Strings.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string name="app_name"&gt;Splitr&lt;/string&gt;
      &lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="btnSplit"&gt;Split&lt;/string&gt;
      &lt;string name="btnTip"&gt;+ Tip&lt;/string&gt;
      &lt;string name="txtSplit"&gt;Split By&lt;/string&gt;
      &lt;string name="txtHint"&gt;Enter Bill Total&lt;/string&gt;
      &lt;string name="spinnerSplit"&gt;No. of People&lt;/string&gt;
      &lt;string name="dialog_split_pay"&gt;Each Person Pays&lt;/string&gt;
      &lt;string name="OK"&gt;OK&lt;/string&gt;
  
  &lt;array name="arraySplitr"&gt;
      &lt;item&gt;2&lt;/item&gt;
      &lt;item&gt;3&lt;/item&gt;
      &lt;item&gt;4&lt;/item&gt;
      &lt;item&gt;5&lt;/item&gt;
      &lt;item&gt;6&lt;/item&gt;
      &lt;item&gt;7&lt;/item&gt;
      &lt;item&gt;8&lt;/item&gt;
      &lt;item&gt;9&lt;/item&gt;
      &lt;item&gt;10&lt;/item&gt;
  &lt;/array&gt;
  </code></pre>
  
  <p></p>
  
  <p>actvity_main.xml</p>
  
  <pre><code>RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  tools:context="com.hydr0dr4gon.splitr.MainActivity"&gt;
  
  &lt;TableLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_alignParentTop="true"
      android:layout_alignParentStart="true"
      android:paddingLeft="40dp"
      android:paddingTop="80dp"
      android:paddingRight="40dp"
      android:paddingBottom="80dp"&gt;
  
      &lt;TableRow
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
          &lt;EditText
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_span="2"
              android:inputType="number"
              android:ems="10"
              android:id="@+id/editText"
              android:layout_column="0"
              android:layout_weight="1.5"
              android:hint="@string/txtHint" /&gt;
  
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
          &lt;TextView
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:text="@string/txtSplit"
              android:id="@+id/txtSplit"
              android:layout_weight="1"
              android:textSize="32dp"
              android:textAlignment="center"
              android:gravity="center" /&gt;
  
          &lt;Spinner
              android:layout_width="0dp"
              android:layout_height="match_parent"
              android:id="@+id/spinner"
              android:layout_weight="1"
              android:spinnerStyle="@android:style/Widget.Spinner.DropDown"
              android:textAlignment="center"
              android:entries="@array/arraySplitr"
              android:prompt="@string/spinnerSplit"/&gt;
  
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
          &lt;Button
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="@string/btnTip"
              android:id="@+id/btnTip"
              android:layout_weight="1" /&gt;
  
          &lt;Button
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="@string/btnSplit"
              android:id="@+id/btnSplit"
              android:layout_weight="1" /&gt;
      &lt;/TableRow&gt;
  
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>logcat</p>
  
  <pre><code>&gt; 07-11 21:18:50.899  10290-10290/com.hydr0dr4gon.splitrv2 D/ActivityThread﹕ handleBindApplication:com.hydr0dr4gon.splitrv2
  07-11 21:18:50.899  10290-10290/com.hydr0dr4gon.splitrv2 D/ActivityThread﹕ setTargetHeapUtilization:0.75
  07-11 21:18:50.899  10290-10290/com.hydr0dr4gon.splitrv2 D/ActivityThread﹕ setTargetHeapMinFree:2097152
  07-11 21:18:51.198  10290-10290/com.hydr0dr4gon.splitrv2 D/AndroidRuntime﹕ Shutting down VM
  07-11 21:18:51.206  10290-10290/com.hydr0dr4gon.splitrv2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.hydr0dr4gon.splitrv2, PID: 10290
      java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
              at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
              at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
              at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:193)
              at android.widget.Spinner.onMeasure(Spinner.java:482)
              at android.view.View.measure(View.java:16521)
              at android.widget.TableRow.getColumnsWidths(TableRow.java:312)
              at android.widget.TableLayout.findLargestCells(TableLayout.java:508)
              at android.widget.TableLayout.measureVertical(TableLayout.java:473)
              at android.widget.TableLayout.onMeasure(TableLayout.java:439)
              at android.view.View.measure(View.java:16521)
              at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
              at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
              at android.view.View.measure(View.java:16521)
              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
              at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
              at android.view.View.measure(View.java:16521)
              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
              at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327)
              at android.view.View.measure(View.java:16521)
              at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
              at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
              at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2552)
              at android.view.View.measure(View.java:16521)
              at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
              at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
              at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
              at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
              at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
              at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
              at android.view.Choreographer.doCallbacks(Choreographer.java:574)
              at android.view.Choreographer.doFrame(Choreographer.java:544)
              at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
              at android.os.Handler.handleCallback(Handler.java:733)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5137)
              at java.lang.reflect.Method.invoke(Native Method)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
  </code></pre>
  
  <p>Thanks.</p>