CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View 203
Once you code your transferDataValues( ) method, which we are about to get into next, your
onCreate( ) method will be quite compact, with only five key lines of code, and yet it will be doing
quite a lot of work, thanks to the three methods that you have coded during this chapter. Your
MainActivity.java class will have five important Java methods to use for your application functions
instead of just the two that Eclipse created for you earlier.
Let’s have Eclipse ADT write some more Java code for us, as it is always so much more fun
watching someone else (or something else, in this particular case) do all of the work whenever
possible!
Add a new-line under the createUiTextViews( ) method call in your onCreate( ) method, type in the
name of your third method, transferDataValues( ), and hit the semi-colon character to complete
this Java (method call) statement, and watch the familiar wavy red error underline highlighting
appear, as you had expected.
Mouse-over the red error highlighting, and bring up the Eclipse error message helper pop-up, and
then select the create method ‘transferDataValues( )’ option so that a method bootstrap code
structure will be written for you.
Inside of the method, we are going to call a .setText( ) method off of your nameData TextView
object to, as you might suspect from the logical method name, set the text value of this nameData
TextView object. Since we want to use the galaxyName variable’s data value to set the text with,
Figure 6-33. Duplicate the TextView UI objects instantiation for the other six data fields for the Galaxy object