title: Passing ListView by using Intent
body: <p>I have created a List View containing- </p>
  
  <ul>
  <li>"Baby Items"</li>
  <li>"Bakery"</li>
  <li>"Baking"</li>
  <li>"Beverages"</li>
  <li>"Canned Goods"</li>
  <li>"Cereal Breakfast"</li>
  <li>"Condiments"      </li>
  <li>"Dairy"</li>
  <li>"Frozen Foods"</li>
  <li>"Miscellaneous"</li>
  <li>"Non-Food Items"  </li>
  <li>"Pasta / Rice"</li>
  <li>"Snacks"</li>
  </ul>
  
  <p>Then, I want to create an onClick layout to each list view also. </p>
  
  <blockquote>
    <p>How can I use intent for the Baby_Items layout if I click on the Baby Items in Shopping Items (ListView)</p>
  </blockquote>
  
  <h1>Shopping Items (JAVA)</h1>
  
  <pre><code>public class ShoppingItems extends ActionBarActivity {
  ListView listView;
  ArrayAdapter&lt;String&gt; adapter;
  String[] item_category = {"Baby Items", "Bakery", "Baking",
          "Beverages", "Canned Goods", "Cereal Breakfast", "Condiments",
          "Dairy", "Frozen Foods", "Miscellaneous", "Non-Food Items",
          "Pasta / Rice", "Snacks"};
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_shopping_items);
      listView = (ListView) findViewById(R.id.list_view);
      adapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,item_category);
      listView.setAdapter(adapter);
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Toast.makeText(getBaseContext(),parent.getItemAtPosition(position)+ " is selected",Toast.LENGTH_LONG).show();
          }
      });
  
  }
  </code></pre>
  
  <h1>BABY_ITEMS (JAVA)</h1>
  
  <pre><code>public class Baby_Items extends ActionBarActivity {
  
  ArrayList&lt;Products&gt; products = new ArrayList&lt;Products&gt;();
  ListAdapter boxAdapter;
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_baby__items);
  
      ListView lvMain = (ListView) findViewById(R.id.lvbabyitems);
      lvMain.setAdapter(boxAdapter);
  }
  
  void fillData() {
      for (int i = 1; i &lt;= 20; i++) {
          products.add(new Products("Products " + i, i * 100, false));
  
      }
  }
  
  public void showResult(View v) {
      String result = "Selected Product are :";
      int totalAmount=0;
      for (Products p : boxAdapter.getBox()) {
          if (p.box){
              result += "\n" + p.name;
              totalAmount+=p.price;
          }
      }
      Toast.makeText(this, result+"\n"+"Total Amount:="+totalAmount, Toast.LENGTH_LONG).show();
  }
  </code></pre>