title: Android - Global Variables and TextView objects
body: <p>I'm currently teaching myself Android programming, so please explain your answers in a way that a beginner could understand.</p>
  
  <p>I'm trying to edit the text in a TextView object using public static String objects from other screens/activities.
  There are two public static string objects, called crew_id and orderType respectively (both are initialized as empty strings). There is a TextView object in an Activity called NewOrderActivity with the id "crew_id_and_ordertype".</p>
  
  <p>My code for NewOrderActivity.class is currently this:</p>
  
  <p>The code for the button to start the NewOrderActivity is:</p>
  
  <pre><code>public void goToNewOrder(View view)
  {
      final EditText edit =  (EditText) findViewById(R.id.editText1); //gets the string from the EditText object
      crew_id = edit.getText().toString();
      Intent k = new Intent(CrewIDActivity.this, NewOrderActivity.class);
      startActivity(k);
  }
  </code></pre>
  
  <p>The code for NewOrderActivity is:</p>
  
  <pre><code>public class NewOrderActivity
  extends Activity{
  TextView info = (TextView)findViewById(R.id.crew_id_and_ordertype);
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_new_order);
      info.setText("Crew ID: " + CrewIDActivity.crew_id + "/n /n" + OrderingActivity.orderType);
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.new_order, menu);
      return true;
  }
  </code></pre>
  
  <p>When I try to go to from the previous activity to NewOrderActivity, the app stops working.
  What am I doing wrong? Is it a problem with how I'm trying to edit the TextView object, or is it something else?</p>