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

测试

布局技巧


相关推荐
qq_452396233 小时前
第十篇:《自动化处理验证码:OCR、接口绕过与第三方服务》
android·自动化·ocr
a8a3024 小时前
Laravel 10.x核心特性深度解析
android
HeeRiver6 小时前
VSCode调用deepseek-v4-pro/flash api的方法
ide·vscode·api·deepseek-v4
angerdream6 小时前
Android手把手编写儿童手机远程监控App之UUID
android
dalancon6 小时前
Android OomAdjuster流程
android
河婆墟邓紫棋6 小时前
MIUI中的权限
android·github
我命由我123458 小时前
Java 开发 - CountDownLatch 不需要手动关闭
android·java·开发语言·jvm·kotlin·android studio·android-studio
众少成多积小致巨8 小时前
GNU Make 核心指南
android·c++
凛_Lin~~8 小时前
安卓进程保活方案记录(双重fork+文件锁+手搓parcel)
android·安卓
海天鹰8 小时前
安卓相机:获取最近拍摄的照片缩略图做相册按钮图标
android