Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Change the Hello World app to allow the entering of a first and a last name and display Hello firstname lastname! when the button

1. Change the Hello World app to allow the entering of a first and a last name and display Hello firstname lastname! when the button is clicked. Be sure to label the EditTexts to reflect the new data that is to be input.
2. Add a Clear button. The Clear button should remove any data in the EditText(s) and change the display back to Hello world!
image text in transcribed
image text in transcribed
Figure 3.9 Initial run of Hello World! Note Either close the activity hello_world.xml file or switch to the Text view after you are done editing it. The reason is that if you close Android Studio with the layout file open in Design view, Android Studio will take a long time opening the project the next time you want to work on it. Coding App Behavior Code to give behavior to the layout is written and stored in the Java class file associated with the layout. Open the HelloWorldActivity.java file by double-clicking it. Ifit is already open, click its tab in the editor. You should see the basic code structure (Listing 3.5). Note that you may have to expand the import section by clicking the button to the left of the keyword import. Listing 3.5 Initial Activity Code 1 pckage com.example.mycompany.helloworld; import android.os.Bundle; 4 import android.support.v7.app.AppCompatActivity; 6 public class HelloWorldActivity extends AppCompatActivity eOverride protected void onCreate (Bundle savedInstanceState) super.onCreate (savedInstanceState); setContentView (R.layout.activity hello world) 10 12 13 This code was generated when you created the activity at the start of the Hello World project. It is important to understand what this code does to properly code an activity Line 1-At the top of the file is the keyword "package" followed by com.example.helloworld This identifies this class as belonging to the Hello World package. All source Java files (in sre folder) will have this entry as the first code in the file Lines 3-4 After the package line and before any other code are the imports. Click the plus (+sign in front of the import..ine of code. You should now see two import lines. This code is used to get the source code needed for your activity. The AppCompatActivity class provides the functionality required by any class that uses or interacts with other Activities used in this class. The Bundle import requires a bit more explanation. In Line 3, a Bundle is an object for passing data between activities. In this way, we can have an

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

n = 1 while n Answered: 1 week ago

Answered: 1 week ago