title: Android app from bootcamp book crashes when written with Android Studio
body: <p>the sample app in Android Bootcamp book was written for Eclipse, but when I wrote it in Android Studio, I can't see the Spinner options and the app keep crashing when I click the Find Ticket Cost,</p>
  
  <p>here is how the app looks like in the AVD</p>
  
  <p><a href="https://www.dropbox.com/s/k5pmw0a5gqrfbd2/Screen%20Shot%202015-03-27%20at%2012.43.06%20PM.png?dl=0" rel="nofollow">https://www.dropbox.com/s/k5pmw0a5gqrfbd2/Screen%20Shot%202015-03-27%20at%2012.43.06%20PM.png?dl=0</a></p>
  
  <p>it's a single Activity app here is the main xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_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="net.androidbootcamp.concerttickets.Main"&gt;
  
  &lt;TextView android:text="Ticket Vault" android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:textSize="40sp"
      android:id="@+id/textView" /&gt;
  
  &lt;EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:inputType="number"
      android:ems="10"
      android:id="@+id/txtTickets"
      android:layout_below="@+id/textView"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="68sp"
      android:hint="Number of Tickets"
      android:textSize="30dp" /&gt;
  
  &lt;!-- no reference for the spinner here values here, they are stored at the strings.xml file that will be handled in Java --&gt;
  &lt;Spinner
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/txtGroup"
      android:layout_below="@+id/txtTickets"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="45dp"
      android:prompt="@string/title" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:id="@+id/txtResult"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="51dp" /&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Find Ticket Cost"
      android:id="@+id/btnCost"
      android:layout_below="@+id/txtGroup"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="57dp"
      android:textSize="30dp" /&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/imageView"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>and here is the main java</p>
  
  <pre><code>package net.androidbootcamp.concerttickets;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.EditText;
  import android.widget.Spinner;
  import android.widget.TextView;
  import android.widget.Button;
  import android.view.View;
  
  import java.text.DecimalFormat;
  
  
  public class Main extends Activity {
  
  //declaring variables
  double costPerTicket=59.99;
  int numberOfTickets;
  double totalCost;
  String groupChoice;
  
  @Override
  
  //customary to launch the Activity
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      // the EditTicket is stored in tickets. final , will not be changed .
      final EditText tickets=(EditText) findViewById(R.id.txtTickets);
      // the spinner is stored at group
      final Spinner group = (Spinner) findViewById(R.id.txtGroup);
      Button cost = (Button) findViewById(R.id.btnCost);
      final TextView result = ((TextView) findViewById(R.id.txtResult));
      //button onClickListener
      cost.setOnClickListener (new View.OnClickListener (){
  
          @Override
          public void onClick(View v){
  
              numberOfTickets = Integer.parseInt(tickets.getText().toString());
              totalCost = costPerTicket * numberOfTickets;
              DecimalFormat currency = new DecimalFormat("`$`###,###.##");
              groupChoice = group.getSelectedItem().toString();
              result.setText("Total Cost for "+ groupChoice + " is " + currency.format(totalCost));
  
          }
  
      });
  
     // final TextView result =((TextView) findViewById (R.id.txtResult));
  }
  
  
  @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();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p>and here is the catlog, I can see that it's complaining about the result variable, but not sure why the Spinner is not displayed:</p>
  
  <pre><code>03-26 13:01:26.120      868-868/net.androidbootcamp.concerttickets D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
  03-26 13:01:27.140      868-868/net.androidbootcamp.concerttickets D/﹕ HostConnection::get() New Host Connection established 0xb7c64238, tid 868
  03-26 13:01:27.180      868-868/net.androidbootcamp.concerttickets W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  03-26 13:01:27.190      868-868/net.androidbootcamp.concerttickets D/OpenGLRenderer﹕ Enabling debug mode 0
  03-26 13:01:40.370      868-868/net.androidbootcamp.concerttickets D/dalvikvm﹕ GC_FOR_ALLOC freed 73K, 5% free 3108K/3252K, paused 28ms, total 30ms
  03-26 13:01:40.380      868-868/net.androidbootcamp.concerttickets I/dalvikvm-heap﹕ Grow heap (frag case) to 4.173MB for 1127536-byte allocation
  03-26 13:01:40.420      868-881/net.androidbootcamp.concerttickets D/dalvikvm﹕ GC_FOR_ALLOC freed 2K, 4% free 4206K/4356K, paused 31ms, total 31ms
  03-26 13:01:40.590      868-868/net.androidbootcamp.concerttickets W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  03-26 13:01:46.670      868-868/net.androidbootcamp.concerttickets W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
  03-26 13:01:48.460      868-868/net.androidbootcamp.concerttickets W/EGL_emulation﹕ eglSurfaceAttrib not implemented
  03-26 13:01:48.880      868-868/net.androidbootcamp.concerttickets W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
  03-26 13:01:53.550      868-868/net.androidbootcamp.concerttickets D/AndroidRuntime﹕ Shutting down VM
  03-26 13:01:53.550      868-868/net.androidbootcamp.concerttickets W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb1b05ba8)
  03-26 13:01:53.560      868-868/net.androidbootcamp.concerttickets E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: net.androidbootcamp.concerttickets, PID: 868
  java.lang.NullPointerException
          at net.androidbootcamp.concerttickets.Main`$`1.onClick(Main.java:46)
          at android.view.View.performClick(View.java:4438)
          at android.view.View`$`PerformClick.run(View.java:18422)
          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:5017)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit`$`MethodAndArgsCaller.run(ZygoteInit.java:779)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>here is my strings xml
      
      Concert Tickets
      Main</p>
  
  <pre><code>&lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
  &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
  &lt;string name="title"&gt;Select Group&lt;/string&gt;
  
  &lt;string-array name="Groups"&gt;
      &lt;item&gt;Dragonly&lt;/item&gt;
      &lt;item&gt;Nine Volt&lt;/item&gt;
      &lt;item&gt;Red Road&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my AndroidManifest xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name=".Main"
          android:label="@string/title_activity_main"&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>your help will be appreciated</p>