title: Can I pass a parameter from a layout XML to a method in the MainActivity?
body: <p>I'm sorry if this is a noob question but I'm new to XML and Android as a whole.</p>
  
  <p>I am making a basic calculator in Android, and basically I want to write a method to handle all of the numerical button presses. I want to pass in a parameter into the method from the XML like so..</p>
  
  <pre><code> &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_weight="1"
          android:text="@string/button_8"
          android:textSize="40dp"
          android:onClick="num_pressed(8)" 
   /&gt;
  </code></pre>
  
  <p>and have that method in the main activity do whatever with that number (I haven't decided what exactly to do with it yet, but that isn't part of my question).</p>
  
  <p>So to clarify, in my app I have buttons for numbers 0-9, symbols "+", "-", "*", "/", "." and "C". Instead of writing a separate method for each number I thought it would be more efficient to have all of the numbers use the same method, and simply pass in a variable so it works for them all in the same way.</p>
  
  <p>Can I do this or do I have to go about it completely differently?</p>