CHAPTER 14: Android Content Providers: Providing Data to Applications 533
As you can see in Figure 14-22, you will first need to mouse over the wavy red error highlighting
and select the Import ‘Button’ (android.widget) option to have Eclipse write the import android.
widget.Button; statement that can be seen at the top of Figure 14-23. Once this is done, you can
instantiate the listButton Button object by using the following two lines of Java code; the first
instantiates an object and a second sets up an event handler:
Button listButton = (Button)findViewById(R.id.listRulers);
listButton.setOnClickListener( new View.OnClickListener() { Your event handler onClick method will
go in here });
Figure 14-22. Declare Button objects named listButton, milkyWayButton, andromedaButton, spiralButton, and HomeButton
Figure 14-23. Instantiate a listButton Button object and call a .setOnClickListener( ) method using the Java new keyword
Once this infrastructure is in place, you can mouse over the wavy red error highlighting under the
View class reference and select an Import ‘View’ (android.view) option. This will write the import
android.view.View; statement. After this import statement is in place, you can again mouse over
the remaining error and select the Add unimplemented methods option to write the bootstrap
(empty) onClick( ) method for your event handler.