<TextView android:id="@+id/anID" />
<TextView android:layout_below="@id/anID" />
<Button
android:text="New Button"
android:id="@+id/button"/>
<ImageButton
android:src="@drawable/IMAGE"
/>
<CheckBox
android:text="Checkbox Text"
/>
<RadioGroup>
<RadioButton android:text="Radio Button 1"/>
<RadioButton android:text="Radio Button 2"/>
</RadioGroup>
<ToggleButton
android:textOff="OFF"
android:textOn="ON" />
<Switch
android:text="Switch Label" />
<Spinner
android:entries="@array/ChoicesFromFile" />
<ImageView
android:src="@drawable/ImageFile" />
int numericalId = R.id.myId;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
<Button
android:text="New Button"
android:id="@+id/button"
android:onClick="aMethod"/>
Button myButton = (Button) getViewById('myButtonId');
myButton.setOnClickListener(new MyListenerObject());
class MyListenerObject implements OnClickListener{
public void onClick(View v) {
\\Respond to event
}
}