public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_layout_id);
final Button button = findViewById(R.id.button_id);
//////////////////////////////////
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// CODE
}
});
//////////////////////////////////
}
}
< button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button"
android:text=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
< button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button"
android:text=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
< LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="2" />
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="3" />
< View
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="5" />
< /LinearLayout>