package app.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Test extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Retrieve the button object
Button myButton = (Button)findViewById(R.id.myButton);
//Attach the listener
myButton.setOnClickListener(clickListener);
}
//Listener object to handle the click events
View.OnClickListener clickListener = new View.OnClickListener() {
public void onClick(View v) {
}
};
}
//main.xml
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Button"
/>