[Solved] How do you attach a function to a button in Eclipse?


The easiest way to do what you want is to make use of the onClick attribute.

Add this attribute to your Button element:

android:onClick="sendSMS"

Android will then try to call a sendSMS method in your activity. It takes a View as a parameter (which will be set to the view you clicked) so you need to change your method to:

public void sendSMS(View view)

This is all covered in the documentation here:
http://developer.android.com/guide/topics/ui/controls/button.html

solved How do you attach a function to a button in Eclipse?