【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);
    }

测试

布局技巧


相关推荐
美狐美颜SDK开放平台7 小时前
准备开发直播APP?视频美颜SDK接入前的十项检查清单
android·ios·音视频·直播美颜sdk·视频美颜sdk
传奇开心果编程7 小时前
【Jetpack Compose娓娓道来】第26课:Repository模式与数据层设计——数据的唯一入口
android·移动开发·1024程序员节·jetpack compose·编程语言理论·编程框架·声明式ui
三少爷的鞋12 小时前
Kotlin 协程,重点就在「协」这个字上
android·kotlin
好的佩奇12 小时前
Dart 之模式
android·flutter·dart
淡淡的香烟14 小时前
Flutter实现多语言切换
android·flutter·1024程序员节
风别鹤15 小时前
Xcode pod ‘xxx/xxx.h‘ file not found
ide·macos·xcode
AIsoft_868916 小时前
手机视频转文字工具清单:哪些APP支持录屏识别
android·音视频
_祝你今天愉快19 小时前
Paint Cavans高级绘制:[一]Paint画笔高级应用
android
@zulnger20 小时前
安卓进行稳定性测试
android·appium·1024程序员节
不吃凉粉20 小时前
android 副屏连接
android