title: how to return value to parameter in between getintent and putintents
body: <p>I have this product getters and setters i want the boolean below (boolean=added) to be changed to true when it is clicked and back to false when its clicked again. More information below: code below is the getters and setters</p>
  
  <pre><code> package kfc.project;
  
      public class Product {
  
  
          String name;
          int servingSize;
          int calories;
          int fat;
          int saturatedFat;
          int transFat;
          int cholesterol;
          int sodium;
          int carbs;
          int fiber;
          int sugar;
          int protein;
          int vitamina;
          int vitaminc;
          int calcium;
          int iron;
          boolean added;
  
          public Product (String name, int servingSize, int calories, int fat, int saturatedFat, int transFat, int cholesterol, int sodium, int carbs, int fiber, int sugar, int protein, int vitamina, int vitaminc, int calcium, int iron){
              this.name=name;
              this.calories=calories;
              this.servingSize=servingSize;
              this.fat=fat;
              this.saturatedFat=saturatedFat;
              this.transFat=transFat;
              this.cholesterol=cholesterol;
              this.fiber=fiber;
              this.sugar=sugar;
              this.sodium=sodium;
              this.carbs=carbs;
              this.protein=protein;
              this.vitamina=vitamina;
              this.vitaminc=vitaminc;
              this.calcium=calcium;
              this.iron=iron;
              added = false;
          }
  
          @Override
          public String toString(){
  
                  return name;
  
          }
  
          public Product (String name, int servingSize){
              this.name=name;
              this.servingSize=servingSize;
          }
  
          public String getName() {
              return name;
          }
  
          public int getServingSize() {
              return servingSize;
          }
  
          public int getCalories() {
              return calories;
          }
  
          public int getFat() {
              return fat;
          }
  
          public int getSaturatedFat() {
              return saturatedFat;
          }
  
          public int getTransFat() {
              return transFat;
          }
  
          public int getCholesterol() {
              return cholesterol;
          }
  
          public int getSodium() {
              return sodium;
          }
  
          public int getCarbs() {
              return carbs;
          }
  
          public int getProtein() {
              return protein;
          }
  
          public int getFiber(){
              return fiber;
          }
  
          public int getSugar(){
              return sugar;
          }
          public int getVitaminA(){
              return vitamina;
          }
          public int getVitaminC(){
              return vitaminc;
          }
          public int getCalcium(){
              return calcium;
          }
          public int getIron(){
              return iron;
          }
          public void setAdded(boolean x){
              added = x;
          }
          public boolean getAdded(){
              return added;
          }
  
      }
  </code></pre>
  
  <p>This is the arraylist where the information is stored and is transfered to a list view</p>
  
  <pre><code>package kfc.project;
  
  import java.util.ArrayList;
  
  public class ProductList {
      ArrayList&lt;Product&gt; list;
  
  
      public ProductList (){
          list = new ArrayList&lt;Product&gt;();
  
          //CREATE PRODUCT HERE
          Product chicken;
          list.add(new Product("Chicken", 10, 20, 30, 40, 50, 60, 70, 80, 90, 80,70,60,50,40,30));    
  
          Product rice;
          list.add(new Product("Rice",11));
      }
  
      public String[] getNames (){
          int c = 0;
          int size = list.size() - 1;
          String[] names = new String[size];
  
          while (size &gt;= c) {
              //names.add(list.get(c).getName());
              names[c] = list.get(c).getName();
              c++;
          }
  
          c = 0;
  
          return names;
      }
  
      public ArrayList&lt;Product&gt; getList (){
          return list;
      }
  
  }
  </code></pre>
  
  <p>Here is the code for the listview where there is an intent that transfers it to another java file where the xml file is located</p>
  
  <pre><code>package kfc.project;
  
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.app.ListActivity;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class ProductListView extends ListActivity {
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {       
          super.onCreate(savedInstanceState);
  
          final ProductList pl = new ProductList();
  
          //setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, PRODUCTS));
          setListAdapter(new ArrayAdapter&lt;Product&gt;(this, R.layout.list_item, pl.getList() ));
  
          ListView lv = getListView();
          lv.setTextFilterEnabled(true);
  
          lv.setOnItemClickListener(new OnItemClickListener() {
  
            public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
              // When clicked, show a toast with the TextView text
              Toast.makeText(getApplicationContext(), "View Product", Toast.LENGTH_SHORT).show();
  
              Product product = pl.getList().get(position);
              // intent stuff for product detail
              Intent intent = new Intent(ProductListView.this, productdetail.class);
              //!!!!!!!!!!!!!!!!!!!!!!!!!!
              //intent.putCharSequenceArrayListExtra("list", pl.getList());
              intent.putExtra("name",product.getName());
              intent.putExtra("serving size", product.getServingSize());
              intent.putExtra("calories", product.getCalories());
              intent.putExtra("fat", product.getFat());
              intent.putExtra("saturated fat", product.getSaturatedFat());
              intent.putExtra("trans fat", product.getTransFat());
              intent.putExtra("cholesterol", product.getCholesterol());
              intent.putExtra("sodium", product.getSodium());
              intent.putExtra("carbs", product.getCarbs());
              intent.putExtra("fiber", product.getFiber());
              intent.putExtra("sugar", product.getSugar());
              intent.putExtra("protein", product.getProtein());
              intent.putExtra("vitamina", product.getVitaminA());
              intent.putExtra("vitaminc", product.getVitaminC());
              intent.putExtra("calcium", product.getCalcium());
              intent.putExtra("iron", product.getIron());
              intent.putExtra("added", product.getAdded());
  
              ProductListView.this.startActivity(intent);
  
              //startActivity(new Intent("kfc.project.productdetail"));
            }
  
          });
  
      }
  
  }
  </code></pre>
  
  <p>Now this is the xml java file wherein i want to define boolean whenever the button is clicked. How can i do this</p>
  
  <pre><code>package kfc.project;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class productdetail extends Activity{
  
      @Override
      protected void onCreate(Bundle bundle) {
          // TODO Auto-generated method stub
          super.onCreate(bundle);
          setContentView(R.layout.productdetail);
          //stuff to get intent
          Intent receivedIntent = getIntent();
  
  
          String productName = receivedIntent.getStringExtra("name");
          int productServingSize = receivedIntent.getIntExtra("serving size",0);
          int productCalories = receivedIntent.getIntExtra("calories",0);
          int productFat = receivedIntent.getIntExtra("fat",0);
          int productSaturatedFat = receivedIntent.getIntExtra("saturated fat",0);
          int productTransFat = receivedIntent.getIntExtra("trans fat",0);
          int productCholesterol = receivedIntent.getIntExtra("cholesterol",0);
          int productSodium = receivedIntent.getIntExtra("sodium",0);
          int productCarbs = receivedIntent.getIntExtra("carbs",0);
          int productFiber = receivedIntent.getIntExtra("fiber",0);
          int productSugar = receivedIntent.getIntExtra("sugar",0);
          int productProtein = receivedIntent.getIntExtra("protein",0);
          int productVitaminA = receivedIntent.getIntExtra ("vitamina",0);
          int productVitaminC = receivedIntent.getIntExtra ("vitaminc",0);
          int productCalcium = receivedIntent.getIntExtra ("calcium",0);
          int productIron = receivedIntent.getIntExtra ("iron",0);
          boolean added = receivedIntent.getBooleanExtra("added", false);
  
          //BUTTONS
          Button addButton = (Button) findViewById(R.id.button1);
          Button removeButton = (Button) findViewById(R.id.button3);
  
          Bundle extras = getIntent().getExtras();
  
          String name = extras.getString("name");
  
          if (name != null) {
              TextView text1 = (TextView) findViewById(R.id.productname);
              text1.setText(productName);
  
          }
  
          //SHOW/HIDE 'ADD' &amp; 'REMOVE' BUTTONS
          if (added==false) {
              //HIDE 'REMOVE' BUTTON
              removeButton.setVisibility(View.GONE);
              //SHOW 'ADD' BUTTON
              addButton.setVisibility(View.VISIBLE);  
          }else{
              //SHOW 'REMOVE' BUTTON
              removeButton.setVisibility(View.VISIBLE);   
              //HIDE 'ADD' BUTTON         
              addButton.setVisibility(View.GONE); 
          }
  
          addButton.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  //added=true;
              }       
          });
  
          removeButton.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  //added=false;
              }       
          });
  
  
              TextView text2 = (TextView) findViewById(R.id.servingsize);
              text2.setText(""+productServingSize);
  
              TextView text3 = (TextView) findViewById(R.id.calories);
              text3.setText(""+productCalories);
  
              TextView text4 = (TextView) findViewById(R.id.totalfat);
              text4.setText(""+productFat);
  
              TextView text5 = (TextView) findViewById(R.id.saturatedfat);
              text5.setText(""+productSaturatedFat);
  
              TextView text6 = (TextView) findViewById(R.id.transfat);
              text6.setText(""+productTransFat);
  
              TextView text7 = (TextView) findViewById(R.id.cholesterol);
              text7.setText(""+productCholesterol);
  
              TextView text8 = (TextView) findViewById(R.id.sodium);
              text8.setText(""+productSodium);
  
              TextView text9 = (TextView) findViewById(R.id.totalcarbohydrates);
              text9.setText(""+productCarbs);
  
              TextView text10 = (TextView) findViewById(R.id.fiber);
              text10.setText(""+productFiber);
  
              TextView text11 = (TextView) findViewById(R.id.sugar);
              text11.setText(""+productSugar);
  
              TextView text12 = (TextView) findViewById(R.id.protein);
              text12.setText(""+productProtein);
  
              TextView text13 = (TextView) findViewById(R.id.vitamina);
              text13.setText(""+productVitaminA);
  
              TextView text14 = (TextView) findViewById(R.id.vitaminc);
              text14.setText(""+productVitaminC);
  
              TextView text15 = (TextView) findViewById(R.id.calcium);
              text15.setText(""+productCalcium);
  
              TextView text16 = (TextView) findViewById(R.id.iron);
              text16.setText(""+productIron);
  
  
  
  
          /*
          Intent intent = getIntent();
          String str = intent.getStringExtra("name");*/
  
      }
  
  
  
  
  
  }
  </code></pre>