title: Passing value from a ListView to another activity
body: <p>I'm trying to get data to pass from a list view to the activity it opens. However when clicking on the listView it crashes my app. </p>
  
  <p>I can't see what's wrong with my code and looking at numerous other examples I'm unsure what is going wrong. The listView was working fine before I started trying to pass data through.</p>
  
  <pre><code>public class SuitableFarmerActivity extends AppCompatActivity {
  
  
          private String[] farmerArray = {"John Smith, 28 days, £2800", "Ben Shaw, 31 days, £2400", "Tom Freer, 32 days, £3400", "Sam Jones, 24 days, £3600"};
  
          private ListView farmerListView;
          private ArrayAdapter arrayAdapter;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_suitable_farmer);
  
              farmerListView = (ListView) findViewById(R.id.farmerList);
  
              arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, farmerArray);
              farmerListView.setAdapter(arrayAdapter);
  
              farmerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
                                          long id) {
  
                      Object obj = farmerListView.getAdapter().getItem(position);
                      String value= obj.toString();
                      Intent confirm = new Intent(SuitableFarmerActivity.this, ConfirmOrderActivity.class);
                      confirm.putExtra("value", value);
  
                      startActivity(confirm);
  
                  }
              });
          }
  
  }
  </code></pre>
  
  <p>Above is my activity code.</p>
  
  <p>Below is the code I'm using to try and retrieve the data in the next activity.</p>
  
  <pre><code>  Bundle recdData = getIntent().getExtras();
      String myVal = recdData.getString("value");
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_confirm_order);
  
          TextView textView = (TextView)findViewById(R.id.textView);
  
          textView.setText(myVal);
  </code></pre>
  
  <p>Any help greatly appreciated.</p>