Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Develop a basic mobile app sequence in this milestone. Ensure all steps have been completed and your code is functioning properly. Zip and upload the
Develop a basic mobile app sequence in this milestone. Ensure all steps have been completed and your code is functioning properly. Zip and upload the developed milestone.To create the second activity, follow these steps:
In the Project window, rightclick the app folder and select New Activity Empty Activity.
In the Configure Activity window, enter "DisplayMessageActivity" for Activity Name. Leave all
other properties set to their defaults and click Finish.
Android Studio automatically does three things:
Creates the DisplayMessageActivity file.
Creates the layout file activitydisplaymessage.xml which corresponds with
the DisplayMessageActivity file.
Adds the required at the top of the layout.
The new activity includes a blank layout file, Follow these steps to add a text view to where the message
appears:
Open the file app res layout activitydisplaymessage.xml
Click Enable Autoconnection to Parent
in the toolbar. This enables Autoconnect. See
figure
In the Palette panel, click Text, drag a TextVlew into the layout, and drop it near the topcenter
of the layout so that it snaps to the vertical line that appears. Autoconnect adds left and right
constraints in order to place the view in the horizontal center.
Create one more constraint from the top of the text view to the top of the layout, so that it
appears as shown in figure
Optionally, you can make some adjustments to the text style if you expand textAppearance in
the Common Attributes panel of the Attributes window, and change attributes such
as textSize and textColor.
Display the message
In this step, you modify the second activity to display the message that was passed by the first activity.
In DisplayMessageActivity, add the following code to the amCreated method:
KotlinJava
override
protected void onCreateBundle savedinstanceState
super.onCreatesavedinstanceState;
setContentViewRlayout.activitydisplaymessage;
Get the Intent that started this activity and extract the string
Intent intent getintent;
String message intent.getStringExtraMainActivityEXTRAMESSAGE;
Capture the layout's TextView and set the string as its text
TextView textView findViewByldRidtextView;
textView.setTextmessage;Press AltEnter, or OptionReturn on a Mac, to import these other needed classes:
Kotlinuava
import androidx,.appcompat.app.AppCompatActivity;
import android.content. Intent;
import android.os Bundle;
import android. widget. Text View;
Add upward navigation
Each screen in your app that's not the main entry point, which are all the screens that aren't the home
screen, must provide navigation that directs the user to the logical parent screen in the app's hierarchy.
To do this, add an Up button in the app ba
To add an Up button, you need to declare which activity is the logical parent in
the AndroidManifest.xml file. Open the filc at app manifests AndroidManifest.xml locate
the sactivity: tas for DisplayMessageActivity, and replace it with the following:
The Android system now automatically adds the Up button to the app bar.
Run the app
Click Apply Changes in the toolbar to run the app. When it opens, type aurmessage in the text field
and tap Send to see the message appear in the second activity:Figure App opened, with text entered on the left screen and displayed on the right.
That's it you've built your first Android appl
When you are done, zip the project and submit it under the assigned bin.
Note: it is very important that you submit the project as a zip file in order to be uploaded.
KB
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started