热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Android编程技术基础第三次大作业

安卓编程技术基础带三次

第一部分:简答题(15分)

  1. 写出5个常见的组件以及常用的页面布局(5分)

  2. 两个Activity之间怎么传递数据?(5分)

  3. 简述ListSetMap集合的区别?(5分)

第二部分:仿QQ登录功能(85

功能要求:

1.开启显示开机页面,3秒后跳转到登录页面:

2. 点击登录按钮,当帐号和密码有一个未填写时,则友情提示帐号密码不能为

3.当帐号密码都填写了,但帐号密码填错给予错误提

4.当帐号密码填写正确,跳转到登录成功页面,并有欢迎语

5. 当点击退出,则弹出对话框提示是否退出

具体要求及推荐实现步骤:

 1.设计登录窗口UI 界面和登录成功后UI 主界面窗口,摆放正确的控件

 2.编写activity 底层处理代码,获取界面控件对象

 3.在activity 注册登录按钮点击事件,判断账号密码,并作出相应提示

 4.Intent 把账号名称传递数据到跳转的主界面的activity 显示欢迎语

 5.正确账号密码:1、zhangsan,123;2、lisi,456;3、wangwu,147。

 6.颜色对应:#1EB9F2 

评分标准:

序号

功能列表

功能描述

分数

1

应用程序

能正确并完整创建应用程序

10

2

界面

按要求设计界面并正确摆放控件

20

3

登录功能

点击登录并对输入的账号密码进行判断,并做出相应提示

35

4

欢迎页

完成页面跳转并实现数据传递,显示欢迎语,退出提示框

20


答案
# 简答题
  1. 写出5个常见的组件以及常用的页面布局(5分)

    Button
    按钮
    TextView
    文本
    EditText
    输入框
    Spinner
    下拉列表
    RadioButton
    单选按钮
    LinearLayout
    线性布局
    TableLayout
    表格布局
    RelativeLayout
    相对布局
  2. 两个Activity之间怎么传递数据?(5分)

    两个Activity之间通过Intent对象进行值的传递

  3. 简述ListSetMap集合的区别?(5分)

    List
    有序允许有重复值
    Set
    无序不予许有重复值
    Map
    以键值对的形式存值,值可以重复,键不可以重复

# 项目结构

    使用了三个Activity,项目结构:


# 使用的图片资源


# java代码
  • MainActivity.java

    package vip.wfb.bigwork3;




    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.Window;
    import android.view.WindowManager;


    public class MainActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //去除activity上边的框框
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //设置全屏显示
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);




    new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
    //第一个参数,当前上下文。第二个参数,计时结束之后开启的页面
    Intent intent = new Intent(getApplicationContext(), DengluActivity.class);
    startActivity(intent);
    finish();
    }
    }, 3000);


    }
    }

    • ZhuyeActivity.java

      package vip.wfb.bigwork3;




      import android.app.Activity;
      import android.content.DialogInterface;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.View;
      import android.view.Window;
      import android.widget.Button;
      import android.widget.TextView;
      import android.widget.Toast;


      import androidx.appcompat.app.AlertDialog;


      import java.util.HashMap;
      import java.util.Map;


      public class ZhuyeActivity extends Activity {
      //声明组件
      private TextView text;
      private Button but_tuichu;
      private Map map = new HashMap();


      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //去掉顶部的小框框
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.activity_zhuye);
      //获取组件
      but_tuichu = findViewById(R.id.but_tuichu);
      text = findViewById(R.id.text_we);
      //账号与人名对应
      map.put("zhangsan", "张三");
      map.put("lisi", "李四");
      map.put("wangwu", "王五");
      //获取用户登录的账号
      final Intent intent = getIntent();
      String name = intent.getStringExtra("name");
      text.setText("欢迎您:" + map.get(name));
      //创建单击监听
      but_tuichu.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      new AlertDialog.Builder(ZhuyeActivity.this)
      .setTitle("确认退出")
      .setIcon(R.drawable.ic_launcher_foreground)
      .setMessage("是否确认退出!")
      .setPositiveButton("确定", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      Intent intent1 = new Intent(getApplicationContext(), DengluActivity.class);
      startActivity(intent1);
      finish();
      }
      })
      .setNegativeButton("取消", new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
      Toast.makeText(getApplicationContext(), "取消退出!", Toast.LENGTH_LONG).show();
      }
      })
      .create()
      .show();
      }
      });


      }
      }

      • DengluActivity

        package vip.wfb.bigwork3;




        import android.app.Activity;
        import android.content.Intent;
        import android.os.Bundle;
        import android.view.View;
        import android.view.Window;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.Toast;


        import java.util.HashMap;
        import java.util.Map;
        import java.util.Set;


        public class DengluActivity extends Activity {
        //声明组件
        private Button but_denglu;
        private EditText edit_name;
        private EditText edit_pwd;
        //定义业务逻辑所需要的变量
        private Map<String, String> map = new HashMap<String, String>();
        private String name;
        private String pwd;
        boolean isName = false;


        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //去掉顶部的框框
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_denglu);
        //获取组件
        but_denglu = findViewById(R.id.but_denglu);
        edit_name = findViewById(R.id.edit_name);
        edit_pwd = findViewById(R.id.edit_pwd);
        //储存账号密码
        map.put("zhangsan", "123");
        map.put("lisi", "456");
        map.put("wangwu", "147");
        //创建单击监听
        but_denglu.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
        //获取用户输入的值
        name = edit_name.getText().toString();
        pwd = edit_pwd.getText().toString();
        //判断是否有忘记输入的内容
        if (name.equals("") || name == null) {
        Toast.makeText(getApplicationContext(), "请输入账号!", Toast.LENGTH_LONG).show();
        } else if (pwd.equals("") || pwd == null) {
        Toast.makeText(getApplicationContext(), "请输入密码!", Toast.LENGTH_LONG).show();
        } else {
        //判断输入的账号是否存在
        Set<String> set = map.keySet();
        for (String st : set) {
        if (st.equals(name)) {
        isName = true;
        }
        }
        if (isName) {
        //判断密码输入是否正确
        if (map.get(name).equals(pwd)) {
        //账号密码都正确跳转界面
        Intent intent = new Intent(getApplicationContext(), ZhuyeActivity.class);
        intent.putExtra("name", name);
        startActivity(intent);
        finish();
        } else {
        Toast.makeText(getApplicationContext(), "密码错误!", Toast.LENGTH_LONG).show();
        }
        } else {
        Toast.makeText(getApplicationContext(), "没有此账号!", Toast.LENGTH_LONG).show();
        }
        }
        }
        });


        }
        }


        # layout代码


        • activity_main.xml


          <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/welcom"
          android:orientation="vertical">



          LinearLayout>

          • activity_zhuye.xml


            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <TextView
            android:id="@+id/text_we"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:gravity="center_vertical"
            android:background="#1EB9F2"
            android:textColor="#ffffff"
            android:textSize="30sp" >


            <Button
            android:id="@+id/but_tuichu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="90dp"
            android:layout_marginRight="30dp"
            android:background="#1EB9F2"
            android:text="退出"
            android:textColor="#ffffff"
            android:textSize="30sp" >
            LinearLayout>

            • activity_denglu.xml


              <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">


              <ImageView
              android:layout_width="match_parent"
              android:layout_height="90dp"
              android:layout_gravity="center"
              android:layout_marginTop="60dp"
              android:src="@drawable/qq" >


              <EditText
              android:id="@+id/edit_name"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="20dp"
              android:layout_marginTop="20dp"
              android:layout_marginRight="20dp"
              android:hint="QQ账号/手机号/邮箱"
              android:singleLine="true" >


              <EditText
              android:id="@+id/edit_pwd"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginLeft="20dp"
              android:layout_marginTop="20dp"
              android:layout_marginRight="20dp"
              android:hint="密码"
              android:inputType="textPassword"
              android:singleLine="true" />


              <Button
              android:id="@+id/but_denglu"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="20dp"
              android:background="#1EB9F2"
              android:text="登录"
              android:textColor="#ffffff"
              android:textSize="20sp" />


              LinearLayout>



              #效果图#



              推荐阅读
              • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
              • android listview OnItemClickListener失效原因
                最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
              • Mac OS 升级到11.2.2 Eclipse打不开了,报错Failed to create the Java Virtual Machine
                本文介绍了在Mac OS升级到11.2.2版本后,使用Eclipse打开时出现报错Failed to create the Java Virtual Machine的问题,并提供了解决方法。 ... [详细]
              • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
              • XML介绍与使用的概述及标签规则
                本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
              • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
              • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
              • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
              • CSS3选择器的使用方法详解,提高Web开发效率和精准度
                本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
              • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
              • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
              • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
              • Spring特性实现接口多类的动态调用详解
                本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
              • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
              • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
              author-avatar
              W14154988
              这个家伙很懒,什么也没留下!
              PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
              Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有