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

测试

布局技巧


相关推荐
青莲8431 小时前
查找算法详解
android·前端
青莲8431 小时前
排序算法详解
android·前端
zd2005722 小时前
用摩斯密码「听」时间:一款安卓报时应用的诞生
android
不会写代码的猴子2 小时前
Android17版本更新预览
android·android studio
用户41659673693553 小时前
记一次深坑:RecyclerView + FlexboxLayoutManager 导致 canScrollVertically 误判的剖析与修复
android
Be for thing4 小时前
Android 音频硬件(Codec / 喇叭 / 麦克风)原理 + 功耗与问题定位实战(手机 / 手表通用)
android·学习·智能手机·音视频
吉哥机顶盒刷机4 小时前
S905L3A/L3AB芯片迎来安卓14新纪元:Sicha移植版固件深度评测与刷机指南
android·经验分享·刷机
一个天蝎座 白勺 程序猿4 小时前
KingbaseES数据库MySQL兼容性解析:从TCO账本到“傻瓜式“迁移的密码
android·数据库·mysql·kingbasees
Be for thing4 小时前
Android 存储硬件(RAM/UFS/eMMC)底层原理 + 性能 / 功耗测试实战
android·学习·智能硬件