05 Chapter Three Exercises

3-1 Briefly describe the specific steps of using Eclipse to create and run Android applications.

(1) Start Eclipse, then select "File (F)" / "New (N)" / "Project ® ..." menu item, will open the "New Project" dialog box, in the dialog
box, select the folder Android Android Application Project, click the "Next (N)>" button.
(2) the pop-up "New Android Application" dialog box, which is first to enter the application name, project name and package name, and then points
respectively in the Minimum Required SDK, Target SDK, Compile With Theme drop-down list and select run The minimum version of the Android
program, the version of the Android program created , the version used when compiling, and the theme used.
(3) Click the "Next" button to open a dialog box for configuring the storage location of the project. The default settings are used here.
(4) Click the "Next" button to open the Configure Launcher Icon dialog box, which can
set the icon-related information of the Android program .
(5) Click the "Next" button to open the Create Activity dialog box, which is used to set the Activity template to be generated. The
default is here . Click the "Next" button to open the New Blank Activity dialog box. This dialog box sets up the relevant information of the Activity, including the
name of the Activity, the name of the layout file, etc. The default is here. Click the "Finish" button to create an Android program. After the program is created, Eclipse
will automatically open the project.
(6) In the package explorer, select the project you want to run (AccountMS here), and click on the Eclipse toolbar
Button to pop up a
dialog box for selecting project operation mode. Select "Android Application" and click the "OK" button. The "Starting AccountMS" dialog box will be displayed. After the
startup is completed, the dialog box will be closed automatically, and the emulator dialog box will be opened to start the emulator.
(7) After the simulator is started, the simulator with the locked screen will be displayed. After the screen is unlocked, the running result of the project will be displayed.

Briefly describe the role of R.java and AndroidManifest.xml files.

The R.java file is used to define the index of all resources in the Android program. When writing code in the Java source file, you can directly access
various resources through this index .
Every Android application must include an AndroidManifest.xml file, which is located in the root directory. It is the global
description file of the entire Android application . In this file, you need to indicate the name of the application, the use of icons, Activity and Service and other information, otherwise the program cannot start normally.

3-3 Which subdirectories are included in the res directory and what are their functions?

The res directory also includes drawable, layout and values ​​subdirectories. The functions of each subdirectory are as follows:
 drawable subdirectory The
drawable subdirectory is usually used to store image resources. Due to the variety of Android devices, the size of their screens are also different. In order to ensure good
good user experience, it will provide different resolutions, different graphics are stored in different folders, by default, ADT plug-in will automatically create
built drawable-xxhdpi (Super Ultra), drawable-xhdpi (Super high), drawable-hdpi (high), drawable-mdpi (medium) and drawable-ldpi
(low) are 5 folders for storing super high resolution pictures, super high resolution pictures, and high resolution respectively High-resolution pictures, medium-resolution pictures and low-resolution
pictures.
 layout subdirectory The
layout subdirectory is mainly used to store the layout files in the Android program. When creating the Android program, an
activity_main.xml layout file is generated by default .
 The values ​​subdirectory The
values ​​subdirectory is usually used to store the strings, styles, and size resources used in the application.

3-4 Briefly describe the specific steps to create and start the Android emulator through Eclipse.

(1) Click the
icon on the Eclipse toolbar to display the AVD Manager dialog box.
(2) Click the "Create ..." button will bring up the "Create new Android Virtual Device (AVD )" dialog box, in the dialog box, first input
the name you want to create AVD, AVD and select the version; then set the SD card Memory size and select the screen style.
(3) Click the "OK" button to return to the "Android Virtual Device Manager" dialog box, and you can see that an AVD has been created.
(4) Select the AVD that has been created, and click the Start... button, and a startup option dialog box will pop up. In this dialog box, the size of the emulator screen can
be scaled, and the default settings are used here.
(5) Click the Launch button to start the simulator. After the first start, you need to click the OK button to enter the main interface of the simulator.
(6) When the simulator is started again, the lock screen interface will be displayed. Swipe up on the screen until the small lock becomes larger and the color becomes pure white. Stop
sliding to unlock the Android emulator. Complete the start of the simulator.

3-5 What is the command to create AVD and start Android emulator in the command line window?

(1) Obtain the available Android platform version, the command format is as follows:
android list targets
(2) Create AVD, the command format is as follows:
android create avd -n <avd name> -t <Android version> -p <AVD device save location> -s <select AVD skin> -d <CPU/ABI>
For example, to create an AVD device named MyAVD_arm that uses ARM (armeabi-v7a) CPU, you can use the following code:
android create avd -n MyAVD_arm -t 1- s HVGA -b default/armeabi-v7a
(3) Start the emulator via AVD. The command format is as follows:
emulator -avd <AVD name>
For example, to start the emulator through the AVD named MyAVD_arm, you can use the following command.
After the emulator -avd MyAVD_arm
command is executed, an emulator will be started.

3-6 How to delete AVD?

Generally, deleting AVD can also be achieved through two methods, one is through a graphical interface, and the other is through a command line.
They are introduced separately below.

The steps to delete an AVD through a graphical interface are relatively simple, just select the AVD to be deleted in the "Android Virtual Device Manager" dialog box, and then click the
Delete button.
 Through the command line The
created AVD can be deleted through the android delete avd command. The specific command format is as follows:
android delete avd -n <AVD name>
For example, to delete the AVD named MyAVD_arm, you can use the following command.
android delete avd -n MyAVD_arm

Guess you like

Origin blog.csdn.net/weixin_44522477/article/details/111860279
Recommended