2017-2018-2 20165315 Experimental Report on Android program design

Source: Internet
Author: User

2017-2018-2 20165315 Experiment Four "Android program design" experimental report 24th: The first knowledge of Android
    • Android StudioThe project's directory tree

1 Build: This directory contains auto-generated files that include compilation settings, r classes, etc.

2 Libs: This directory contains the library files needed to develop Android apps

3 src: This directory holds the application's source code. java files. By default, it contains the Mainactivity.java file, and the source code J is part of the function you need to launch the app when you click on the app icon.

4 Res: This directory holds all the resource files

5 drawable: This directory holds the Drawable object and some picture resources for the project

6 layout: This directory contains layouts files for each interface.

7 Menu: This directory holds the menus objects that are designed in the app

8 mipmap: This directory holds the application's main picture resources

9 Values: This directory holds a collection of resources defined by strings, colors, and so on

10 androidmanifest.xml: This file is a file that describes the underlying characteristics of the application and defines each component.

Task One:
- 参考```http://www.cnblogs.com/rocedu/p/6371315.html#SECANDROID```,安装 Android Stuidio- 完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号,自己学号前后一名同学的学号- 学习Android Stuidio调试应用程序

Experimental process:

    • Change the layout file to activity_main.xml android:text="Hello World!"android:text="Hello World20165315!"

Run:

    • Learn Android Stuidio Debug app

The debugging process is as follows: Tools AndroidAndroid Device Monitor

25th Chapter: Activities
    • The four components of Android
      • Activity
      • Service
      • ContentProvider
      • Broadcast Receiver
    • For Activity , it is the most commonly used and most common component of the Android system.
    • An application typically contains multipleActivity
    • Activityclass defines the following callback events
      • onCreate(): This is the first callback method. It is called when activity is first created
      • onStart: This method is recalled when activity becomes visible to the user
      • onResume(): This method is called when the user starts interacting with the app
      • onPause(): When the current activity is paused and the previous activity is recovering, the suspended activity will no longer receive input from the user or execute any code and calls
      • onStop(): This callback method is called when activity is no longer a visual state
      • onDestroy(): This method is called before the activity is destroyed by the system
      • onRestart(): The callback method is called when the activity is restarted after it has been stopped
Task Two
创建 ThirdActivity, 在ThirdActivity中显示自己的学号,修改代码让MainActivity启动ThirdActivity
    • Configure activity
      • In file Androidmanifest.xml, you can configure activity as long as you add activity child elements to the application element
      • In this task, we need to call thirdactivity, so add another activity in the Androidmanifest.xml
    • Start and close activity
      • Each control file activity requires a corresponding startup program file (. java) and the corresponding layout file (. xml)
      • In this task, ask Mainactivity to start thirdactivity, so you need to modify the Mainactivity

Run:

26th Chapter: UI Components
    • Android provides a number of UI components that you can build on-demand user interface for your app
      • TextView: A text label that is used to display text
      • EditText: text box, a subclass of pre-defined TextView, with rich text editing capabilities
      • AutoCompleteTextView: Auto-complete text label, similar to EditText. When the user enters the time will automatically give some complete suggestions
      • Button: button, can press, click, by the user to complete an action
      • ImageButton: Picture button, as the name implies
      • CheckBox: A check box that can be used as a switch for users. This control is recommended when you have a series of options to choose from
      • ToggleButton: Switch button with a "bulb" effect
      • RadioButton: Radio button, only checked and unchecked
      • RadioGroup: Is a collection of RadioButton, only one radio button can be selected within the same group
      • Spinner: A drop-down list that allows the user to select one of several options
      • TimePicker: Time picker allows users to enter time with 12-hour and 24-hour modes
      • DatePicker: Date selector allows the user to enter a date
      • ProgressBar: A progress bar that provides the user with the progress of a work, such as what is being done in the background
Task Three
修改代码让Toast消息中显示自己的学号信息

Modify the MainActivity code as follows:

package yh.is.besti.edu.cn.uitest;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.Gravity;import android.view.View;import android.widget.Button;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.RelativeLayout;import android.widget.TextView;import android.widget.Toast;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        Button btnshow1 = (Button) findViewById(R.id.btn1);        btnshow1.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                Toast toast = Toast.makeText(MainActivity.this, "20165211", Toast.LENGTH_LONG);                toast.show();            }        });    }}

Run:

27th Chapter: Layout
    • Types of layouts
      • Linear layout LinearLayout : A linear layout is a view group (ViewGroup) that can line up all child elements in a single direction, either horizontally or vertically
      • Relative layout RelativeLayout : A relative layout is a layout that displays a child view in a relative position
      • Table layout TableLayout : Table layout is a view of grouping child elements in rows and columns
      • Absolute layout AbsoluteLayout : Absolute layout allows you to specify the exact location of child elements
      • Frame layout FrameLayout : Frame layout is a placeholder on the screen that you can use to display a single view
      • List view ListView : The list layout is scrollable and is the view group used to display a list of child elements
      • Grid view GridView : A grid view is a group of views that displays child elements in a two-dimensional scrollable grid
Task Four
修改布局让P290页的界面与教材不同
    • Modify activity_main.xml The content, the code is as follows:
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="horizontal">    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="100dp"        android:layout_marginTop="100dp"        android:text="20165211" />    <FrameLayout        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="20165211"></FrameLayout>    <Button        android:id="@+id/button"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" /></FrameLayout>

Run:

28th Chapter: Listener Task Five
构建项目,运行教材相关代码

Run:

Problems encountered and their solutions
    • After installing Androidstudio, error occurred gradle project sync failed

Resolution process:
Find a blog on the Internet, which describes the solution in detail:

Open the Web page http://services.gradle.org/distributions/ , select the corresponding version of the gradle you want, and then put it in the C:\Users\ user name. Gradle\wrapper\dists\gradle-4.1-all folder (This package does not need to be decompressed)

    • In the process of solving the above problem, I found that the Mac computer will automatically unzip the downloaded compressed package

Resolution process:
The uncompressed zip file was found in the Trash bin:)

    • The first run Hello World , the R class has been marked red, the hint file can not find the R class

Resolution process:

After a query on the Web, the answer is found in a blog post:

1. Clean Project:build->clean Project

2. Rebuild Project:build->rebuild Project

3, and restart the application and even the system: File->invalidata Caches/restart->invalidata and Restart

    • Virtual Android phone failed to start

Resolution process:

Seems to be the problem with the phone model, the use of Nexus 5X API 27×86 this problem occurs, but the use of Nexus 5 API 27 this problem does not occur

Experience and summary of experiment

The experiment was entirely new, and Java was developed in a field--android we had never been in contact with before. To complete this experiment, we have a general understanding of the process and framework of Android development, laying the foundation for further study and broadening our horizons. There have been a lot of problems with installing Android Studio, and I've been more aware of the success of the installation in the process of finding solutions. When the results appear on the virtual phone page, I really feel the widespread use of Java in Android applications, and the interest in Java is deeper.

PSP (Personal software Process) time
Steps Time Consuming percentage
Steps Take Percentage
Demand analysis 60min 26%
Design 30min 13%
Code implementation 90min 39%
Test 20min 9%
Analysis Summary 30min 13%
Code Cloud Link

Https://gitee.com/BESTI-IS-JAVA-2018/20165315AndroidStudio

2017-2018-2 20165315 Experimental Report on Android program design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.