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

ImageButtons and handling event

This is where we code the ImageButtons click events. Open the Java source code from src/net.kerul.simplenumb3r5/SimpleNumb3r5.java. Here, we will be discussing the main activity class that will provide the screen navigation with the following code:

public class SimpleNumb3r5 extends Activity implements OnClickListener

The main class, as usual, will inherit the Activity class, and implement OnClickListener to enable the widget interaction.

The main variable declarations are as follows:

//initialize all widgets private ImageView imagenumber; private ImageButton btnprevious, btninfo, btnsound, btnnext; //define variables to track screen number, start from 0 private int screennumber=0; //define a sound controller private ...

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