安卓3月21日作业

作业一,界面设计的代码:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
     android:layout_height="match_parent"
    android:layout_width="match_parent">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Please choose a flowe you like!"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:textSize="50dp"
        />

    <ImageView
        android:layout_width="317dp"
        android:layout_height="238dp"
        android:layout_gravity="center"
        android:id="@+id/hua"
        />
    <RadioGroup
        android:id="@+id/g1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal">
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="梅花        "
            android:textSize="20dp"
            android:id="@+id/meihua" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="石榴花       "
            android:textSize="20dp"
            android:id="@+id/shiliuhua" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="象牙花"
            android:textSize="20dp"
            android:id="@+id/xiangyahua" />

    </RadioGroup>
    <RadioGroup
        android:id="@+id/g2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal">
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="绣球花    "
            android:textSize="20dp"
            android:id="@+id/xiuqiuihua" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="玉兰花       "
            android:textSize="20dp"
            android:id="@+id/yulanhua" />
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="牡丹花"
            android:textSize="20dp"
            android:id="@+id/nudanhua"/>

    </RadioGroup>

</LinearLayout>

JAVA代码:

package com.example.woshishen.xuanhuaapplication;

import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class MainActivity extends AppCompatActivity {
    private ImageView H;
    private RadioButton MH;
    private RadioButton SLH;
    private RadioButton XYH;
    private RadioButton XQH;
    private RadioButton YLH;
    private RadioButton MDH;
    private RadioGroup G1;
    private RadioGroup G2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        H = (ImageView) findViewById(R.id.hua);
        MH = (RadioButton) findViewById(R.id.meihua);
        SLH = (RadioButton) findViewById(R.id.shiliuhua);
        XYH = (RadioButton) findViewById(R.id.xiangyahua);
        XQH = (RadioButton) findViewById(R.id.xiuqiuihua);
        YLH = (RadioButton) findViewById(R.id.yulanhua);
        MDH = (RadioButton) findViewById(R.id.nudanhua);
        G1 = (RadioGroup) findViewById(R.id.g1);
        G2 = (RadioGroup) findViewById(R.id.g2);

        G1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (MH.isChecked()) {
                    H.setImageResource(R.drawable.meihua);
                   G2.clearCheck();
                }
                if (SLH.isChecked()) {
                    H.setImageResource(R.drawable.shiliu);
                    G2.clearCheck();
                }
                if (XYH.isChecked()) {
                    H.setImageResource(R.drawable.xiangya);
                    G2.clearCheck();
                }

            }
        });
        G2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (XQH.isChecked()) {
                    H.setImageResource(R.drawable.xiuqiu);
                    G1.clearCheck();
                }
                if (YLH.isChecked()) {
                    H.setImageResource(R.drawable.yulan);
                    G1.clearCheck();
                }
                if (MDH.isChecked()) {
                    H.setImageResource(R.drawable.mudan);
                    G1.clearCheck();
                }

            }
        });

    }
}

作业二布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.woshishen.tupianapplication.MainActivity">

    <ImageView
        android:layout_width="104dp"
        android:layout_height="96dp"
        android:layout_gravity="center"
        android:src="@drawable/tupian"
        android:id="@+id/imageView" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="退出"
        android:id="@+id/tuichu"/>
</LinearLayout>

  JAVA代码:

package com.example.woshishen.tupianapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private ImageView TP;
    private Button TC;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TP = (ImageView) findViewById(R.id.imageView);
        TC = (Button) findViewById(R.id.tuichu);

        TC.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "再按一次退出按钮", Toast.LENGTH_LONG).show();
                TC.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        MainActivity.this.finish();
                    }
                });
            }
        });

    }
    @Override
    public boolean onTouchEvent (MotionEvent event){

        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            float x = event.getX();
            float y = event.getY();
            String la = "X坐标:" + x + ",Y坐标" + y;
            TP.setX(x - 150);
            TP.setY(y - 300);
            Toast.makeText(this,la,Toast.LENGTH_LONG).show();
        }
        return super.onTouchEvent(event);

    }
}

  

时间: 2024-08-05 11:12:55

安卓3月21日作业的相关文章

软考高项学员:2016年4月20日作业

软考高项学员:2016年4月20日作业 一.战略管理1.企业战略的特点有哪些?2.企业战略决策的特点有哪些?3.战略管理分为哪三步?(记)4.组织的使包括组织哲学和组织宗旨,请写下2者的定义.5.要确定一个组织的宗旨,首先做什么?(记)6.什么是长期目标,什么是短期目标?7.战略制订包括哪五个步骤?(记)8.战略分析中的外部分析有哪些?9.宏观趋势分析包括哪些?请列出名称,并简述之.10.行业分析包括哪些?11.五力模型认为,行业中的竞争包括哪五种基本的竞争力量?(记)(可以参看图20.1五力模

软考中高项学员:2016年3月26日作业

软考中高项学员:2016年3月26日作业一.质量管理1.质量管理基本原则?2.质量管理的目标?3.质量管理的主要活动有哪些?(记)4.质量管理流程包括哪四个环节?(记)(按P'DCA理解记忆)5.ISO9000质量管理的8项原则是什么?6.全面质量管理是一种全?.全?.全?的品质管理?它由结构.技术.人员.变革推动者4个要素组成.7.全面质量管理有哪4个核心的特征?8.六西格玛意为六倍标准差,在质量上表示每百万坏品率少于多少?9.六西格玛管理法的核心是什么?而DMAIC是什么意思?包括哪四个要素

软考中高项学员:2016年3月23日作业

软考中高项学员:2016年3月23日作业 一.项目进度管理1.进度管理包括哪六个过程?2.什么是滚动式规划?3.什么是控制账户.规划组合?4.请说明FS.FF.SS.SF的含义.5.虚活动的含义?6.三种依赖关系是哪三种?7.活动资源估算的方法.工具和技术?(记)8.活动历时估算的方法.工具和技术?(记)9.何时可以用类比估算?10.参数估算的含义?11.三点估算公式?标准差计算公式?正负一倍的标准差情况下,概率是多少?2倍的呢?3倍的呢?12.后备分析中,应急时间=时间储备=缓冲时间吗?13.

软考信息系统监理师 2016年3月18日作业

软考信息系统监理师,2016年3月18日作业: 第四章 监理单位的组织建设 1.监理单位的体系建设分为哪3部分? 答:分为业务体系建设.质保体系建设.管理体系建设 2.监理单位监理服务质量管理的方式有2种,哪2种?优缺点是什么? 答:一种是以单位管理为主,一种是以监理项目部自我管理为主. 以单位管理为主的质量管理模式的优点是可以保证单位各个监理项目部按照统一 的要求进行监理,易于控制;缺点是限制了总监理工程师质量控制的积极性,管 理费用大.以监理项目部为主的质量管理模式的优点与缺点正好相反. 3

软考信息系统监理师,2016年3月15日作业

软考信息系统监理师,2016年3月15日作业: 第一章:监理基础 1.目前我国信息服务管理包括哪四个方面措施? 答: (1) 计算机信息系统集成单位资质管理 (2) 信息系统项目经理资格管理 (3) 信息系统工程监理单位资质管理 (4) 信息系统工程监理人员资格管理 2.什么是信息系统工程? 答: 信息化工程建设中的信息网络系统.信息资源系统.信息运用系统的新建.升级.改造工程 3.什么是四控三管一协调? 答: 四控"指信息系统工程的质量控制.进度控制.投资控制.变更控制: "三控&q

Linux运维学习-2——2016年7月21日

格式说明: 操作 概念 命令 说明及举例 二 internet 因特网ethernet 以太网ctrl+alt+F1 图形界面ctrl+alt+F2-F6 字符界面 命令:who am i/who/who me i/tty/df/ifconfig/w/ halt 关机 reboot 重启 chvt 1-6 切换终端 init 3 关闭图形界面 init 5 打开图形界面 cp 复制 pwd 显示当前目录 lsblk 列出硬盘信息 id -u mg 查看用户ID,root为9,其他为普通用户,不加

3月14日作业

2016年3月14日作业: 一.项目管理一般知识 第四章:项目管理一般知识1.核心知识域有哪些.保障域有哪些?伴随域有哪些?过程域有哪些? 答:核心知识域包括:整体管理.范围管理.进度管理.成本管理.质量管理和信息安全管理: 保障域包括:人力资源管理.合同管理.采购管理.风险管理.信息(文档)与配置管理.知识产权管理.法律法规标准规范和职业道德规范. 伴随域包括:变更管理.沟通管理: 过程域包括:科研与立项.启动.计划.实施.监控和收尾等.监控过程可发生在项目生命周期的任一阶段.2.有效的项目管

3月26日作业

软考中高项学员:2016年3月26日作业一.质量管理1.质量管理基本原则? 答:1)以实用为核心的多元要求:2)系统工程:3)职工参与管理:4)管理层和一把手重视:5)保护消费者权益:6)面向国际市场.2.质量管理的目标? 答:1)顾客满意度:2)预防胜于检查:3)各阶段内的过程.此外,实施组织主动采纳的质量改进措施(如全面质量管理.持续改进等)不仅可以提高项目管理的质量,而且也能提高项目产品的质量.3.质量管理的主要活动有哪些?(记) 答:质量策划,质量保证与质量控制过程.4.质量管理流程包括

软考信息系统监理师:2016年4月1日作业

软考信息系统监理师:2016年4月1日作业一.合同管理1.合同按照信息系统工程范围划分哪几类?1)总承包合同:2)单项项目承包合同:3)分包合同. 2.签订分包合同,应具备的2个条件是什么?1)总承建单位只能将自己承包的部分项目分包给具有相应 资质条件的分承建单位:2)分包项目必须经过建设单位同意. 3.分包的禁止性规定有哪些?1)禁止转包:2)禁止将项目分包给不具备相应资质条件的 单位:3)禁止再分包:4)禁止分包主体结构.4.合同按项目付款方式为哪几类?1)总价合同:2)单价合同:3)成本加