android大作业的实现

一、思路

1.大致思路

使用Android Studio,通过已学的基本控件及高级控件,实现页面并完成页面的切换与数据的存储,这里只使用到了sharedPreferences实现了注册信息后验证信息正确及可成功登录,否则显示用户名或密码错误。在这里我创建了4个布局文件(xml)和4个 Activity 文件(java),分别是登录、注册、首页以及首页当中还有个跳转按钮跳转到另一个页面。说明:下面没有的代码新建后未改动。

二、实现

1.效果图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.源代码

2.1 activity_main.xml

<?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:layout_width="wrap_content"
    android:layout_height="600dp"
    android:orientation="vertical"
    android:background="@drawable/bj">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="60dp"
        android:layout_marginLeft="120dp"
        tools:ignore="RtlHardcoded">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="40sp"
            android:textColor="@color/colors4"

            android:text="@string/string1"
            tools:ignore="RtlHardcoded"
            android:autoLink="web"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="60dp"
        android:layout_marginLeft="20dp"
        tools:ignore="RtlHardcoded">
        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="25sp"
            android:text="@string/string2"
            android:textColor="@color/colors3"/>
        <EditText
            android:id="@+id/edit_username"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="15"
            android:layout_marginLeft="10dp"
            android:inputType="textPersonName"
            android:hint="@string/string6"
            android:textSize="25sp"
            android:textColorHint="@color/white"
            android:width="280dp"
            android:height="20dp"
            android:background="@color/colors1"
            android:autofillHints="" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="20dp"
        tools:ignore="RtlHardcoded">
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="25sp"
            android:textColor="@color/colors3"
            android:text="@string/string3" />
        <EditText
            android:id="@+id/edit_password"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="34dp"
            android:inputType="textPersonName"
            android:ems="15"
            android:hint="@string/string7"
            android:textColorHint="@color/white"
            android:width="280dp"
            android:textSize="25sp"
            android:background="@color/colors1"
            tools:ignore="TextFields"
            android:importantForAutofill="no" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="80dp"
        tools:ignore="RtlHardcoded">
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/string4"
            android:textSize="25sp"
            android:textColorHint="@color/white"
            tools:ignore="ButtonStyle">
        </Button>
        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/string5"
            android:textSize=
  • 14
    点赞
  • 142
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值