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

Source: Internet
Author: User

First, the experimental report cover

Ii. contents of the experiment

1. Develop simple Android apps and deploy tests based on Android studio;

2. Understand the use of Android, components, layout manager;

3. Mastering the event handling mechanism in Android.

Third, the experimental steps

(a) installation test of Android Stuidio

Experimental requirements:

    • Refer to the Java and Android Development Learning Guide (second Edition) (Epubit,java for Android 2nd), Chapter 24th:
    • Refer to Http://www.cnblogs.com/rocedu/p/6371315.html#SECANDROID, installing Android Stuidio
    • Finish Hello World, ask to modify the contents of the Res directory, Hello World to show their school number, the number of students before and after a student, submit code run and code cloud GIT link, no study number to deduct points
    • Learn Android Stuidio Debug app

Steps:

    1. android:text= "Hello world!" in the layout file Activity_main.xml Change to android:text= "Hello world20165315!"

      Detailed code:

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World 20165201 20165202 20165203!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>

Run:

(ii) Activity testing

Experimental requirements:

    • Refer to the Java and Android Development Learning Guide (second Edition) (Epubit,java for Android 2nd), Chapter 25th:
    • Build the project, run the textbook related code
    • Create thirdactivity, display your own number in thirdactivity, modify the code to let mainactivity start thirdactivity
    • Submit code to run and code cloud git link, to have a study number watermark, otherwise it will deduct points

Steps:

1.MainActivity:

package cn.edu.besti.is.jhs.secondactivitydemo;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Intent intent = new Intent(this,ThirdActivity.class);        startActivity(intent);    }}

2. file new Activity empty Activity create thirdacticity, top left corner

3.activity_main.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="wyhy.activity.MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="20165202 jhs"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>

4.activity_third.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout 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">    <TextView        android:layout_width="144dp"        android:layout_height="26dp"        android:text="20165202jhs"        tools:ignore="MissingConstraints"        tools:layout_editor_absoluteX="109dp"        tools:layout_editor_absoluteY="242dp" /></android.support.constraint.ConstraintLayout>

Run

Three UI Test

Experimental requirements

    • Refer to the Java and Android Development Learning Guide (second Edition) (Epubit,java for Android 2nd), Chapter 26th:
    • Build the project, run the textbook related code
    • Modify the code to let the toast message display its own learning number information
    • Submit code to run and code cloud git link, to have a study number watermark, otherwise it will deduct points

Steps:

1.main_activity

package cn.edu.besti.is.jhs.ui;import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.Toast;public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        Toast.makeText(this,"20165202",Toast.LENGTH_LONG).show();    }}

2.activity_main.xml

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="wyhy.ui.MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="20165202"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>

Run

(iv) Layout test

Experimental requirements
-Refer to the Java and Android Development Learning Guide (second Edition) (Epubit,java for Android 2nd), Chapter 27th:

    • Build the project, run the textbook related code
    • Modify the layout so that the P290 page interface is different from the textbook
    • Submit code to run and code cloud git link, to have a study number watermark, otherwise it will deduct points

Steps

1.activity_main.xml

<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:paddingleft=" 2DP "an droid:paddingright= "2DP" > <button android:id= "@+id/cancelbutton" android:layout_width= "wrap_content "Android:layout_height=" wrap_content "android:text=" Home "android:layout_marginright=" 80DP "a Ndroid:layout_marginend= "80DP" android:layout_alignbaseline= "@+id/savebutton" android:layout_alignbottom= "@+ Id/savebutton "android:layout_alignparentright=" true "android:layout_alignparentend=" true "/> <Butt On android:id= "@+id/savebutton" android:layout_width= "wrap_content" android:layout_height= "Wrap_conte        NT "android:text=" Back "android:layout_marginbottom=" 100DP "android:layout_alignparentbottom=" true " android:layout_toleftof="@+id/cancelbutton" android:layout_tostartof= "@+id/cancelbutton" android:layout_marginright= "50DP" an droid:layout_marginend= "50DP"/> <imageview android:layout_width= "100DP" android:layout_height= "150 DP "android:padding=" 10DP "android:src=" @android:d rawable/ic_btn_speak_now "android:id=" @+id/imagevie        W "android:layout_centervertical=" true "android:layout_centerhorizontal=" true "/> <linearlayout Android:id= "@+id/filter_button_container" android:layout_width= "match_parent" android:layout_height= "Wra P_content "android:gravity=" Center|bottom "android:background=" @android: Color/white "Android:orientat ion= "Horizontal" android:layout_marginbottom= "50DP" android:layout_above= "@+id/imageview2" Android:la Yout_alignparentleft= "true" android:layout_alignparentstart= "true" > <button android:id= "@+i         D/filterbutton "   Android:layout_width= "Wrap_content" android:layout_height= "fill_parent" android:text= "Filter"/&G        T <button android:id= "@+id/sharebutton" android:layout_width= "Wrap_content" Android:layo            ut_height= "Fill_parent" android:text= "Share"/> <button android:id= "@+id/deletebutton" Android:layout_width= "Wrap_content" android:layout_height= "fill_parent" android:text= "Del Ete "/> </LinearLayout></RelativeLayout>

Run

(v) Event processing testing

Experimental requirements

    • Refer to the Java and Android Development Learning Guide (second Edition) (Epubit,java for Android 2nd), Chapter 28th:
    • Build the project, run the textbook related code
    • Submit code to run and code cloud git link, to have a study number watermark, otherwise it will deduct points

Steps

1.MainActivity

Package Cn.edu.besti.is.jhs.multicolorclock;import Android.support.v7.app.appcompatactivity;import Android.os.bundle;import Android.app.activity;import Android.graphics.color;import Android.os.Bundle;import Android.view.menu;import Android.view.view;import Android.widget.analogclock;import Android.app.Activity;import Android.graphics.color;import Android.os.bundle;import Android.view.menu;import Android.view.View;import    Android.widget.analogclock;public class Mainactivity extends Activity {int counter = 0;            int[] Colors = {color.black, Color.Blue, Color.cyan, Color.dkgray, Color.gray, Color.green, Color.ltgray,    Color.magenta, Color.Red, Color.White, color.yellow};        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);    Setcontentview (R.layout.activity_main);  } @Override Public boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu, this adds items to the action Bar if it//is presEnt.        Getmenuinflater (). Inflate (R.menu.menu_main, menu);    return true;        public void ChangeColor (view view) {if (counter = = colors.length) {counter = 0;    } view.setbackgroundcolor (colors[counter++]); }}

2.activity_main

<RelativeLayout    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:paddingBottom="10dp"    android:paddingLeft="10dp"    android:paddingRight="10dp"    android:paddingTop="10dp"    tools:context=".MainActivity">    <AnalogClock        android:id="@+id/analogClock1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentTop="true"        android:layout_centerHorizontal="true"        android:layout_marginTop="90dp"        android:onClick="changeColor"        /></RelativeLayout>

Run

Touch discoloration

Iv. problems encountered and their solutions

1. Use Andriodstudio for the first time new project when the card is not in the Buiilding interface
The first time you create a new project Andriodstudio will try to download gradle from the official website, the download speed is very slow or can not download at all, so the card in the Buiilding interface can not go in.

Workaround:

    • Open the c:\users< user name >.gradle\wrapper\dists. You will see there is a Gradle-x.xx-all folder in this directory, this is the Gradle version we want to manually download, if x.xx is 1.9, then we will manually download version 1.9, if 1.10, we will manually download Gradle 1.10 version.
    • Gradle
    • After downloading the corresponding version of Gradle, copy the downloaded. zip file (without decompression) to the Gradle-x.xx-all\55gk2rcmfc6p2dg9u9ohc3hw9 folder above
    • When you open Andriodstudio again, it's fast.

2. How do I create a new activity in a project and launch it with other activities?

New activity: In the left directory bar app > manifests > New > Activity > Gallery . Note When you click Manifests, right-click and click Gallery to enter the new activity page.

    • Start another project in one project:

        Intent intent = new Intent(this, SecondActivity.class);//要启动活动就必须要新建一个Intent类的对象,传递的参数分别是启动活动的语句所在活动的名字和被启动的活动的名字  startActivity(intent);//启动活动

3. How do I set up a toast in my activity?

Add the following code to the activity

@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    Toast.makeText(this, "你想要写的内容", Toast.LENGTH_LONG).show();}
Five, PSP time statistics
Steps Time Consuming percentage
Demand analysis 35min 7%
Design 45min 21%
Code implementation 90min 42%
Test 30min 15%
Analysis Summary 21min 11%
Six, the code Cloud link seven, the Experiment experience

The focus of this experiment is on the use of Androidstudio, which focuses on simply modifying the code and running the validator. The first contact Androidstudio did not know many places, encountered many problems in the beginning. It was a little exciting to see the program on the analog Nexus machine after the first run, and I think it was the most interesting one of several experiments.

2017-2018-2 20165202 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.