Your Very First Mobile App: Objective
Your Very First Mobile App: Objective
Objective:
• create a simple Android app using readily available development platforms and environments.
Materials:
Procedure:
General Instructions:
Legend:
4. Under Select the form factors your app will run on, check the box for Phone and Tablet.
5. For Minimum SDK, select API 8: Android 2.2 (Froyo).
6. Leave all of the other options (TV, Wear, and Glass) unchecked and click Next.
7. Under Add an activity to Mobile, select Blank Activity and click Next.
8. Under Customize the Activity, change the Activity Name to MyActivity. The Layout Name
changes to activity_my, and the Title to MyActivity. The Menu Resource Name is menu_my.
9. Click the Finish button to create the project.
Activity 2: Creating an Android Virtual Device (AVD)
1. When using Android Studio to run an app on the emulator, you need to first create an AVD, which
is a device configuration for the Android emulator that allows Android Studio to mimic a specific
device (smartphone, tablet, etc.).
2. Click on Tools – Android – AVD Manager to launch the Android Virtual Device Manager.
3. On the AVD Manager main screen, click Create Virtual Device:
4. In the Select Hardware window, select a device configuration (e.g. Nexus 6), then click Next.
5. Select the desired system version for the AVD. Then, click Next.
6. Click Finish.
res/layout/activity_my.xml
This button doesn't need the android:id attribute because it won't be referenced from the activity
code. The layout is designed so that both the EditText and Button widgets are only as big as
necessary to fit their content:
To improve the layout efficiency when you specify the weight, you should change the width of the
EditText to zero (0dp). Setting the width to zero improves layout performance because using
"wrap_content" as the width requires the system to calculate a width that is ultimately irrelevant
because the weight value requires another width calculation to fill the remaining space:
3. Run the complete app by clicking Run from the toolbar. Debug if errors occur during runtime.
Graded Exercise:
1. Create a new text field and button located below the existing ones.
2. Do the following steps on the new text field and button:
• Replace LinearLayout with RelativeLayout.
• Set the text fields’ and buttons’ height and weight attributes to “wrap_content”.
• Create id attributes for the buttons.
• Add the necessary layout attributes to correctly position the text fields and buttons.
Example:
android:layout_below="@id/edit_message"
android:layout_toRightOf = “@id/edit_message”
3. Inform your instructor once you are finished with your work.
Scoring Criteria:
• App Interface and Control Layouts – detail (cleanliness, orderliness) of the app layout and its
controls (30 points)
• Error-Free – whether the app runs smoothly or with major errors (errors that break the app’s
operation) or minor errors (20 points)