title: Passing data between activities from listview to another activity
body: <p>I am trying to pass the data from this main activity to another activity</p>
  
  <p><em>I am successful in sending data between activities .... Like the data from Edit-text to next activity through <code>putExtra</code> and <code>GetExtra</code> methods and passing as intents</em></p>
  
  <ul>
  <li>But i am facing challenge in this  particular task where it involves
  sending data from listview to an ordinary activity</li>
  <li>data is populated in the list view from JSON so when on click of a
  row how can i send the data from that row to a new activity</li>
  </ul>
  
  <p><strong>Any Ideas,</strong></p>
  
  <hr>
  
  <p><strong>ativity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout 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" &gt;
  
      &lt;ListView
          android:id="@+id/listViewID"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" 
  
          android:layout_gravity="center"&gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  
      // url to make request
      private static String url = "http://54.218.73.244:7002/";
      List&lt;Item&gt; yourData = new ArrayList&lt;Item&gt;();
  
      ProgressDialog progressDialog;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //Instantiating ProgressDialog with onCreate method
          progressDialog=new ProgressDialog(MainActivity.this);
          new ParsingAsync().execute();
  
      }
  
      private class ParsingAsync extends AsyncTask&lt;Void, Void, Void&gt;
      {
  
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
              super.onPreExecute();
              progressDialog=ProgressDialog.show(MainActivity.this, "", "Please Wait", true, false);
  
  
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              // TODO Auto-generated method stub
  
              // Creating JSON Parser instance
              JSONObjParser jParser = new JSONObjParser();
  
              // getting JSON string from URL
              JSONArray json = jParser.getJSONFromUrl(url);
  
              try {
                  for (int i = 0; i &lt; json.length(); i++) {
                      JSONObject c = json.getJSONObject(i);
  
                      // Storing each json item in variable
                      String NAME=c.getString("restaurantNAME");
  
                      yourData.add(new Item(NAME));
                  }
              } catch (JSONException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              super.onPostExecute(result);
              progressDialog.dismiss();
              ListView yourListView = (ListView) findViewById(R.id.listViewID);
              ListAdapter customAdapter = new ListAdapter(MainActivity.this, R.layout.itemlistrow, yourData);
              yourListView.setAdapter(customAdapter);
              yourListView.setOnItemClickListener(new OnItemClickListener() {
  
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                          int position, long id) {
                      // When clicked, show a toast with the TextView text
                      if(position == 0)
                      {
                          //code specific to first list item    
                          Intent myIntent = new Intent(MainActivity.this,CopperChimneyDesc.class);
                          startActivity(myIntent);
                      }else if(position == 1)
                      {
                          //Intent myIntent = new Intent(MainActivity.this,AroyDesc.class);
                          //startActivity(myIntent);                  
                      }
  
                  }
              });
          }
  
      }
  
  }
  </code></pre>
  
  <p><strong>item.java</strong></p>
  
  <pre><code>public class Item{
      private String Name;
  
      public Item(String name){
          this.Name = name;
      }
      public String getName(){
          return Name;
      }
  }
  </code></pre>
  
  <p><strong>Thanks,</strong></p>