Experimental three Android programming

Source: Internet
Author: User

Experiment three Android Programming Course: Java Programming Class: 1652 Name: Kong No.: 20165208 Instructor: Lou Jia Peng Experimental Date: 2018.5.14 Experiment Name: Android Programming Test requirements:
    1. Students who do not have a Linux base are advised to start with the Linux basics (new version) Vim Editor course;
    2. Complete the experiment, write the experimental report, pay attention to the results of the experiment report, the problems encountered (tool search, installation, use, program editing, debugging, running, etc.), solutions (empty methods such as "Check the network", "Ask classmates", "read books" and so on all have 0 points) and analysis (from which can get what revelation, What are the gains, lessons, etc);
    3. The experiment reports the time of their PSP (Personal software Process);
    4. Plagiarism is strictly forbidden.

      Experiment contents, steps and experience

Directory:
    • (i) Installation knowledge Android
    • (ii) Activities
    • (iii) Toast
    • (iv) Layout test
    • (v) Event processing testing
(i) Installation knowledge Android
    • Install Android stuidio
    • finish Hello World, ask to modify the contents of the Res directory, Hello world to display their own school number, the student's number before and after the school number
    • learning Androi D stuidio Debug Application
    • activity_main.xml android:text= "Hello world!" In the Hello world to "Hello world!20165208\n 20165207\n 20165209\n"
    • The complete code is as follows
<?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=".MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World!20165208\n  20165207\n 20165209\n"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" /></android.support.constraint.ConstraintLayout>
    • The experimental results are as follows

Back to Catalog

(ii) Activities

    • Build the project, run the textbook related code
    • Create a thirdactivity, display your own number in thirdactivity, modify the code to let mainactivity start thirdactivity
Import Android.app.activity;import android.content.intent;import android.os.bundle;import android.app.Activity; Import Android.content.intent;import android.view.menu;import android.view.motionevent;import Android.view.View; Import Android.view.view.ontouchlistener;import Android.widget.textview;public class Mainactivity extends Activity Implements Ontouchlistener {@Override protected void onCreate (Bundle savedinstancestate) {super.oncreate        (savedinstancestate);        Setcontentview (R.layout.activity_main);        TextView TV = (TextView) Findviewbyid (R.ID.TEXTVIEW1);    Tv.setontouchlistener (this);  } @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; } @Override public boolean OnTouch (View arg0, motionevent event) {Intent Intent = new Intent (This, thirdacti        Vity.class); Intent.PutExtra ("message", "20165208 hole months");        StartActivity (Intent);    return true; }}

The code runs as follows

Back to Catalog

(iii) Toast

    • Build the project, run the textbook related code
    • Modify the code to let the toast message display its own learning number information
    • The specific code is as follows

Activity_main

<?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 = "Com.example.lxkj.commitzyq3.MainActivity" > <textview android:layout_width= "wrap_content" Android:        layout_height= "Wrap_content" android:text= "20165230" app:layout_constraintbottom_tobottomof= "parent" app:layout_constraintleft_toleftof= "Parent" app:layout_constraintright_torightof= "parent" App:layout_constra inttop_totopof= "Parent" app:layout_constrainthorizontal_bias= "0.318" app:layout_constraintvertical_bias= "0.2 "/> <button android:id=" @+id/btn1 "android:layout_width=" Wrap_content "Android:layout_hei ght= "Wrap_content" Tools:layout_editor_absolutey= "16DP" tools:layout_editor_absolutex= "5DP"/></ Android.support.constraint.constraintlayout>

Mainactivity.java

import android.content.Context;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.app.Activity;import android.util.AttributeSet;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;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,"20165208 孔月", Toast.LENGTH_LONG);                toast.show();            }        });    }

Final Run effect

Back to Catalog

(iv) Layout test

  • Build the project, run the textbook related code
  • Modify the layout so that the P290 page interface is different from the textbook
  • The specific code is as follows

    <relativelayoutxmlns: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: paddingleft= "2DP" android:paddingright= "2DP" ><button android:id= "@+id/cancelbutton" android:layout_width= " Wrap_content "android:layout_height=" wrap_content "android:text=" 20165208 "android:layout_margintop=" 70DP "and Roid:layout_alignparenttop= "true" android:layout_centerhorizontal= "true"/><button android:id= "@+id/ Savebutton "android:layout_width=" wrap_content "android:layout_height=" wrap_content "android:text=" Hole Month "Android : layout_below= "@+id/cancelbutton" android:layout_alignleft= "@+id/cancelbutton" android:layout_alignstart= "@+id/ CancelButton "android:layout_margintop=" 23DP "/><imageview android:layout_width=" 150DP "Android:layout_heig ht= "150DP" android:layout_margintop= "45DP" android:padding= "4DP" android:src= "@android:d rawable/ic_dialog_email "android:id=" @+id/imageview "android:layout_below=" @+id/savebutton "Android:lay Out_centerhorizontal= "true"/><linearlayout android:id= "@+id/filter_button_container" android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_alignparentbottom= "true" android:gravity= "cent Er|bottom "android:background=" @android: Color/white "android:orientation=" Horizontal "> <button Android Oid:id= "@+id/filterbutton" android:layout_width= "wrap_content" android:layout_height= "Fill_parent" an        droid:text= "Filter"/> <button android:id= "@+id/sharebutton" android:layout_width= "Wrap_content" android:layout_height= "Fill_parent" android:text= "Share"/> <button android:id= "@+id/deletebut Ton "android:layout_width=" Wrap_content "android:layout_height=" fill_parent "android:text=" Delete "/& Gt;</linearlayout></relativelayout> 
    Run as follows

    Back to Catalog
    (v) Event processing testing
  • Build the project, run the textbook related code
  • The specific code is as follows

Androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.dell1.helloworld"    android:versionCode="1"    android:versionName="1.0">    <uses-sdk        android:minSdkVersion="8"        android:targetSdkVersion="17" />    <application        android:allowBackup="true"        android:label="@string/app_name"        android:theme="@style/AppTheme">        <activity            android:name="com.example.dell1.helloworld.MainActivity"            android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application></manifest>

    • After a brief adjustment, the running effect
Summary and experience of the problem
    • Issue 1: This experiment installs Android Stuidio to encounter a lot of difficulties, first did not like the teacher's steps written by the Automatic Popup SDK installation interface, but the subsequent operation also shows that the installation. Should not have a major impact on the installation process
    • Issue 2: When installing the plug-in at the end of the installation, click Try again no response, show failed
    • solution: Is the initial download of the Gradle installation package has a problem, After the replacement, it can be installed normally.
    • Issue 3: The next installation I encountered the biggest problem, the display prompt could not find the SDK, but in the SDK installation path I can see that it has been installed and used, and found that the set of mobile phones can not be used, specific problems such as, after the deletion of the phone reset invalid, I went online to find the problem, On-line solutions such as, after several corrections can not be correctly run, and then uninstall installed three times or can not run, but also asked the student TA or can not solve the problem ...

    • Temporary workaround:


    • Experience: This experiment for me a bit difficult, from the installation began to encounter problems, the problem continues until later also did not solve, is really do not know how to solve, On-line search of similar problem solutions have been tried, but did not have any effect, also carried out uninstall installation, but again open when the same problem, then in the help of the teaching elder sister's advice I chose to borrow classmate's computer to complete the experiment.
Steps Time Consuming percentage
Demand analysis Min 8.3%
Design Min 23.3%
Code implementation Min 40%
Test Min 13.3%
Analysis Summary Min 15%

Experimental three Android programming

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.