Once the layout is inflated, you can get references to the individual widgets so that you can interact with them programmatically. To do so, you use class Activity
’s findViewById
method. This method takes an int
constant representing a specific view’s Id and returns a reference to the view. The name of each view’s R.id constant is determined by the component’s Id property that you specified when designing the GUI. For example, amount-EditText
’s constant is R.id.amountEditText
.
Lines 43–51 obtain references to the TextView
s that are changed by the app. Lines 43–44 obtain a reference to the amountDisplayTextView
that’s updated when the user enters the bill amount. Lines 45–46 obtain a reference to the percentCustomTextView
that’s updated when the user changes the custom tip percentage. Lines 47–51 obtain references to the TextView
s where the calculated tips and totals are displayed.
3.17.78.157