O'Reilly logo

Android Development Tools for Eclipse by Sanjay Shah, Khirulnizam Abd Rahman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hook up

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required