Android studio开发一:三个页面简单实现QQ登录界面的延时跳转

Android studio开发

QQ登录界面延时跳转

第一次写博客,平时也会在CSDN里面搜索信息,在本学期新开的课程里学习Android studio编程实验课,简单记录一下实验内容。

一、实验目的

  1. 掌握Android开发环境的搭建;
  2. 了解Android SDK的安装、配置、使用;
  3. 熟悉开发工具Android Studio的使用;
  4. 了解创建项目并熟悉文件目录结构;
  5. 编写一个简单的登录跳转界面,实现延迟跳转,按钮跳转。

二、实验环境

Windows 11、AndroidStudio

三、实验内容和实验步骤

  1. Android开发环境搭建需要安装的软件及作用。

①首先去Android studio官网下载安装包,下载最新版本(支持Android 12的版本);
②安装过程中勾选必要选项(防止缺少组件或者插件支持),安装好之后打开;
③新建一个空项目(Empty Activity)后,点击右上方“No Devices”选择“Device Manager”创建新的虚拟机(Create virtual device),并挑选一个自己喜欢的虚拟机下载安装,或者利用数据线连接自己的手机并打开开发者模式调试功能,软件即可搜索到真机;

创建新的虚拟机
④如果连接真机的话需要下载Google USB Driver支持USB调试功能,并在手机里开启相应权限(开发者模式中允许调试安装程序);
USB调试功能安装
安装好之后重启软件进行加载即可;
⑤最后点击“Make Project” 在这里插入图片描述
构建一下项目,检查是否有忘记安装的环境等等,一切准备就绪之后,无错误跳出可基本确认配置完成。

  1. 使用约束布局完成QQ欢迎界面和登录界面的设计,并完成俩界面之间的跳转,要求提交源码工程,以及运行结果截图。

三、实验内容和实验步骤

1. 第一个界面

Java:

MainActivity.java

MainActivity.java:设置延时界面,时间为3秒。

Xml:

activity_main.xml

activity_main.xml:第一个页面的布局,设置图片“qq.jpg”。(图片最好是png格式或者jpg等通用的图片格式,否则会出现不兼容的情况)

运行截图:

在这里插入图片描述在这里插入图片描述
2. 第二个界面

Java:

SecondActivity.java

SecondActivity.java:设置按钮点击,启动第三个界面,利用Intent方法。

Xml:

activity_second.xml

activity_second.xml:第二个页面的布局,可以点击右上方“Design”进入图形化界面设置,不需要自己手写代码。

这个页面里需要编写按钮代码或者直接在图形化界面拉取“Button”,然后添加监听器,设置点击“click”实现点击跳转。

运行截图:

在这里插入图片描述在这里插入图片描述
3. 第三个界面

Java:

ThirdActivity.java
Xml:

activity_third
运行截图:

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

最后,我在下面附上运行代码,以供大家参考:

// 文件名activity_main.xml,第一个页面布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    android:background="@drawable/qq">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:srcCompat="@drawable/qq" />
</androidx.constraintlayout.widget.ConstraintLayout>
// 文件名SecondActivity.java,第二个页面
package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class SecondActivity extends AppCompatActivity {

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

    public void click(View view){
        //启动第三个界面
        Intent intent=new Intent(this,ThirdActivity.class);
        startActivity(intent);
    }
}
// 文件名activity_second.xml,第二个页面布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".SecondActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/QQ登录界面"
        android:textSize="48sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/登录"
        android:onClick="click"
        android:textSize="24sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.713" />
</androidx.constraintlayout.widget.ConstraintLayout>
// 文件名ThirdActivity.java,第三个页面
package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

        public class ThirdActivity extends AppCompatActivity {

            @Override
            protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);
    }
}
// 文件名activity_third.xml,第三个页面布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".ThirdActivity">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/第三个界面"
        android:textSize="34sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

如果这篇文章对您或是您的朋友有帮助的话,还请各位志同道合的好友多多支持,一起共同进步!!!

有问题的同学或朋友可以在下面留言,看到的话会及时回复的哦~~~

  • 11
    点赞
  • 121
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Zzq_Fighting

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值