Edit the AnalyticsActivity.java file and make the following modifications to add import directives, declare variables and perform initialization tasks in the onCreate() method: package
#ANDROID STUDIO LOGCAT FORMAT TO LINK TO FILE CODE#
Repeat this a second time, this time selecting the Center Vertically option.īefore adding the code to log Analytics events, some steps must first be taken to obtain a reference to the FirebaseAnalytics instance and to add a listener to the RadioGroup container to detect changes to the user’s payment method selection. Change the text property of the Button to “Order” and configure an onClick method named orderItem.įinally, select all of the widgets in the layout, right-click on the Button and select the Center Horizontally menu option. Delete the text property for the EditText view, set the hint property to “Item” and change the ID to itemText. Next, drag and drop the EditText and Button views onto the layout. Using the Properties panel, change the text displayed on the two RadioButtons to read “Cash” and “Credit” with IDs set to cashRadio and creditRadio respectively. Switch the palette to the Widgets category, then drag and drop two RadioButton instances onto the RadioGroup entry in the Component Tree panel as outlined in Figure 41‑2: From the Containers section of the widget palette, locate the RadioGroup object and drag and drop it into position on the layout canvas. Open the activity_analytics.xml file in the layout editor and select and delete the default TextView. The user interfaced for the app consists of a simple layout containing an EditText view, two buttons and a RadioGroup containing two RadioButtons as illustrated in Figure 41‑1 below: Report this ad Designing the User Interface