HarmonyOS 界面跳转以及界面跳转的同时传递参数
HarmonyOS 不带参数界面之间跳转
package com.example.myapplication.slice;
import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;public class MainAbilitySlice extends AbilitySlice {@Overridepublic void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_ability_main);Button button = (Button) findComponentById(ResourceTable.Id_button);button.setClickedListener(new Component.ClickedListener() {@Overridepublic void onClick(Component component) {present(new IntentAbilitySlice(), new Intent());}});}@Overridepublic void onActive() {super.onActive();}@Overridepublic void onForeground(Intent intent) {super.onForeground(intent);}
}
跳转实现的效果图
HarmonyOS 界面跳转的同时传递参数
传递参数界面代码
package com.example.myapplication.slice;
import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;public class MainAbilitySlice extends AbilitySlice {@Overridepublic void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_ability_main);Button button = (Button) findComponentById(ResourceTable.Id_button);button.setClickedListener(new Component.ClickedListener() {@Overridepublic void onClick(Component component) {Intent intent1 = new Intent();intent1.setParam("key","有点困了");present(new IntentAbilitySlice(), intent1);}});}@Overridepublic void onActive() {super.onActive();}@Overridepublic void onForeground(Intent intent) {super.onForeground(intent);}
}
接受值界面代码
package com.example.myapplication.slice;import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;public class IntentAbilitySlice extends AbilitySlice {@Overrideprotected void onStart(Intent intent) {super.onStart(intent);super.setUIContent(ResourceTable.Layout_intent_ability_slice_layout);Text text = (Text) findComponentById(ResourceTable.Id_text);if (intent != null) {text.setText("接受的值为:" + intent.getStringParam("key"));}}
}
实现的效果图如下
HarmonyOS 界面跳转以及界面跳转的同时传递参数相关推荐
- java等待欢迎界面_android welcome欢迎界面3秒后自动跳转
android welcome欢迎界面3秒钟之后自动跳转其实就是将APP的启动页面设置成我们自定义的Activity,而不是原来的MainActivity,方法很简单,如下是详细步骤. 第一步:自定义 ...
- html文字跳转备注,界面跳转备注.html
界面跳转备注 $axure.utils.getTransparentGifPath = function() { return 'resources/images/transparent.gif' ...
- swift 原生给h5发消息_Swift-WKWebView与JavaScript的细节,H5页面跳转原生界面
大家(也包括我)要学会 明白一件事情(注意断句,哈哈).优秀的程序猿会将问题简单化. 世界上有10种人,一种是先把问题复杂化,然后在一点点的做减法:另一种是先把问题简单化,然后在慢慢的做加法:(好了该 ...
- 如何优雅的实现界面跳转 之 统跳协议 - DarwinNativeRouter
PS 感谢大家的关注,由于我本想开源4个库,除了router, 另外三个分别是native dispatcher, web dispatcher 和 react dispatcher , 所以rout ...
- linux登录界面输入密码时卡住6,centos6.8(虚拟机VNC)输入正确用户名和密码仍跳回登录界面...
1)CentOS自动更新到6.8后root无法登陆问题解决 虚拟机CentOS服务器不知道被谁更新系统到6.8后,发现在本机上即使输入正确的密码也无法登陆,发现有一些人也碰见过同样的问题,但是他们是因 ...
- php带参数跳转页面,如何带参数跳转php界面_后端开发
访问php报404错误的原因_后端开发 访问php报404错误的原因:1.php文件丢失或被删除而导致的,可以通过检查php文件是否存在来解决:2.URL访问路径输入错误所导致的,可以通过仔细核对UR ...
- Win10开机跳过欢迎界面直接进系统桌面的设置方法
解决方法一: 1.按下键盘[Win徽标键 + R键],在"关于"窗口中输入"control userpasswords2",回车. 2.打开"用户账户 ...
- 移动端 外部浏览器点击按钮跳转微信界面(唤醒微信)
移动端点击按钮跳转微信界面(唤醒微信) <a href="weixin://">微信app</a> 或者 window.location.href = &q ...
- 基于QT的【第一个项目】设计+所有组件配合使用+网络编程局域网通信+文件IO操作+登录界面和头像+多界面跳转+JSON数据解析+表情包制作
基于QT的第一个项目+所有组件配合使用+网络编程局域网通信+文件IO操作+登录界面和头像+多界面跳转+JSON数据解析+表情包制作 第一阶段 网络编程局域网TCP/IP聊天QT实现 main.c ma ...
最新文章
- java 计算器 小程序_java应用小程序计算器
- python语言入门n-python语言入门之字符串的一些用法
- java 字段验证_Selenium-Gherkin-Java:验证必填字段上的文本
- Mybatis sql注入问题
- 关于压缩工具 7z(7-zip) 的选项 -u(更新压缩档案中的文件)的解读
- Java 结构体之 JavaStruct 使用教程二 JavaStruct 用例分析
- 旧文重发:苹果是怎么吃到的?
- android 图片叠加xml,Android实现图片叠加效果的两种方法
- 用hundred造句子_八个有趣的开学破冰游戏,线上线下都能用
- HDU-神、上帝以及老天爷
- 华为HCNE(H3CNE) / HCSE(H3CSE)认证必看书籍
- exePath must be specified when not running inside a stand alone exe
- linux 截屏_如何在Linux上截图
- 算法笔记:使用A*算法解决八数码问题
- 命令行对文件批量改名
- 微信小程序开发之获取用户信息
- 记录第一次使用python模拟鼠标点击
- 利用python修改Excel内容
- android学习资源大整合(持续更新ing)
- python包编译过程中出现: /usr/local/cuda-9.0/nvcc: No such file or directory问题的简单解决办法