Java tutorial
//package com.java2s; import android.content.Context; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; public class Main { public static Button setActionButton(Context context, LinearLayout linearLayout, View.OnClickListener l) { Button b = new Button(context); b.setText("Click"); linearLayout.addView(b); b.setOnClickListener(l); return b; } }