Button 20160801
//MainActivity

import
android.app.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
Button btn = new Button(this);
btn.setText("Button");
LinearLayout layout = new LinearLayout(this);
layout.addView(btn, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
setContentView(layout);

btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Toast.makeText(getApplicationContext(),"Button onClick", Toast.LENGTH_SHORT).show();
}
});
}
}