zoukankan      html  css  js  c++  java
  • 20155210第四次实验

    20155210第四次实验

    实验内容

    package com.example.dell.myapp;
    
    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;
    import android.widget.Button;
    import android.widget.Toast;
    import android.graphics.Color;
    import android.widget.AnalogClock;
    public class MainActivity extends Activity  {
        /*@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,"20155210潘滢昊", Toast.LENGTH_LONG);
                                                toast.show();
                                            }
                                        });
            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, ThirdActivity.class);
            intent.putExtra("message", "20155210潘滢昊");
            startActivity(intent);
            return true;
        }*/
        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++]);
        }
    }
    
    package com.example.dell.myapp;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Menu;
    import android.widget.TextView;
    public class SecondActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_second);
            Intent intent = getIntent();
            String message = intent.getStringExtra("message");
            ((TextView) findViewById(R.id.textView1)).setText(message);
        }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.menu_second, menu);
            return true;
        }
    }
    
    package com.example.dell.myapp;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Menu;
    import android.widget.TextView;
    public class ThirdActivity extends Activity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_second);
            Intent intent = getIntent();
            String message = intent.getStringExtra("message");
            ((TextView) findViewById(R.id.textView1)).setText(message);
        }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.menu_second, menu);
            return true;
        }
    }
    

    代码截图

    已上传到蓝墨云班课

    实验时间表

    题目思考时间 代码编辑时间 代码调试时间
    时间 120min 120min 120min
  • 相关阅读:
    apue第16章笔记
    重构与重写
    架构方面的笔记
    多进程失败拉起的demo
    Elasticsearch match_phrase用法
    c++风格
    cocos2d-x 3.2 移植到android
    Mac 下配置 Cocos2d-x 3-x android 的环境
    解决最新版的ADT没有NDK选项的问题
    待飞日记(第六天和第七天)
  • 原文地址:https://www.cnblogs.com/panyinghao/p/6881605.html
Copyright © 2011-2022 走看看