title: Android Fragment onClick button Method
body: <p>I'm trying to invoke the method in my onClick (View v) XML, but does not work with Fragment. This is the error.</p>
  
  <pre><code>01-17 12:38:36.840: E/AndroidRuntime(4171): java.lang.IllegalStateException: 
  Could not find a method insertIntoDb(View) in the activity class main.MainActivity 
  for onClick handler on view class android.widget.Button with id 'btn_conferma'
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>public void insertIntoDb(View v) {
  ...
  } 
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;Button
          android:id="@id/btn_conferma"
          style="?android:attr/borderlessButtonStyle"
          android:layout_width="0.0dip"
          android:layout_height="45dp"
          android:layout_marginLeft="2dp"
          android:layout_weight="1.0"
          android:background="@drawable/bottoni"
          android:gravity="center_horizontal|center_vertical"
          android:onClick="insertIntoDb"
          android:text="SALVA"
          android:textColor="#ffffff"
          android:textSize="16sp" /&gt;
  </code></pre>