After doing all the hard work of defining and putting things in place, let's get in to do some action by hooking up everything with the main screen (Main Activity). Open the MainActivity.java
file and let's binds things in now.
Initialize the widgets as follows:
private EditText text; private RadioButton rBtnKm; private RadioButton rBtnMtr; private CheckBox cBoxMile; private CheckBox cBoxFt; private CheckBox cBoxYd;
The onCreate
method is first called to fetch the instances of widgets as follows:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); text= (EditText)findViewById(R.id.distText); rBtnKm=(RadioButton)findViewById(R.id.kmRadiobutton); rBtnMtr= (RadioButton )findViewById(R.id.metreRadioButton); cBoxMile = (CheckBox) findViewById(R.id.checkBoxMile); cBoxFt = (CheckBox) findViewById(R.id.checkBoxFoot); cBoxYd = (CheckBox) findViewById(R.id.checkBoxYard); }