So I have done some research, and after defining you button as an object by the code
private Button buttonname;
buttonname = (Button) findViewById(R.id.butto
in Activity java class you would need a method first to find the view of the button as :
btnSum =(Button)findViewById(R.id.button);
after this set on click listener
btnSum.setOnClickListener(new View.OnClickListener() {
and override onClick method for your functionality .I have found a fully working example here : http://javainhouse.blogspot.in/2016/01/button-example-android-studio.html