title: How to Use buttons in an ArrayList
body: <p>I made an ArrayAdapter and Array list for a "merchandise" kinda view and now i want it so that everytime i I click the + button it increments the products quantity that I want/click on. I'm veeeery new to java and android Soz.</p>
  
  <pre><code>So I wanna add this
  
  int quantity = 1;
  
      /**
       * This method displays the given quantity value on the screen.
       */
      private void displayQuantity(int number) {
          TextView quantityTextView = findViewById(R.id.quantity_text_view);
          quantityTextView.setText(number);
      }
  
  
      /** this method is used to increase quantity*/
      public void add (View view) {
          quantity = quantity + 1;
  
          Log.v("merch","Added +1");
  
          displayQuantity(quantity);
      }
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>public class merchandise extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.grid_view);
  
          ArrayList&lt;Merch&gt; merchArrayList = new ArrayList&lt;Merch&gt;();
          merchArrayList.add(new Merch(R.drawable.icon,"PRODUCT1"));
          merchArrayList.add(new Merch(R.drawable.icon,"PRODUCT2"));
          merchArrayList.add(new Merch(R.drawable.icon,"PRODUCT3"));
          merchArrayList.add(new Merch(R.drawable.icon,"PRODUCT4"));
  
          merchAdapter merchAdapter =  new merchAdapter(this,merchArrayList);
          GridView merchListView = (GridView) findViewById(R.id.merch_grid_view);
          merchListView.setAdapter(merchAdapter);
      }
  </code></pre>
  
  <p>Things I tried: 
  1) created a new class and just called it "merch_buttons", but i got an error saying "the method should be in the parent context to the view" and i don't understand that.
  2) added it to the on create but realized you can't add a method to a method
  3) added it AFTER the on create method but it gave an error saying that "java.lang.IllegalStateException: Could not execute method for android:onClick". </p>
  
  <p>4) Tried to make a very simple new class and an xml with one button and the text view but still got error at 3).... (also asked a question about that).</p>
  
  <p>sooooooo, what to do.</p>