【Android Studio】Intent实现两个Activity页面的跳转(基于Empty View Activity)

文章目录

为什么使用EmptyViewActivity而不是EmptyActivity

因为笔者使用的AndroidStudio版本比较新,经过测试从水母版开始EmptyActivity就不再支持选择JAVA语言,本次实验使用的AndroidStudio版本如下图所示:

准备工作:创建EmptyViewActivity项目


最原始项目结构如下:

准备工作:新建SecondActivity


如下图所示,会多出两个文件:一个是Activity文件,另一个是布局文件

调试一下原始项目


添加button

给MainActivity设置button



写跳转方法

java 复制代码
    public void toSecond(View view) {
        Intent intent =new Intent();
        intent.setClass(this,SecondActivity.class);
        startActivity(intent);
    }

测试

布局技巧


相关推荐
erqi2 小时前
Compose你入门吧
android
q***76562 小时前
MySQL 中如何进行 SQL 调优
android·sql·mysql
zhanglinping6193 小时前
MySQL——内置函数
android·数据库·mysql
m***78743 小时前
mysql之字符串函数
android·数据库·mysql
w***71104 小时前
MySQL 事务的操作和四大特性
android·数据库·mysql
松叶似针5 小时前
Flutter三方库适配OpenHarmony【secure_application】— Android 端 FLAG_SECURE 实现分析
android·flutter
SiYuanFeng6 小时前
vscode中markdown使用单个$显示公式($...$),preview页面里公式显示失败
ide·vscode·编辑器
cjl_8520087 小时前
[MySQL] MySQL复合查询(多表查询、子查询)
android·mysql·adb
stevenzqzq7 小时前
Barrier的用法
android
城东米粉儿8 小时前
Android 窗口添加/删除流程 笔记
android