当前位置:网站首页>【HarmonyOS】【FAQ】鸿蒙问题合集4
【HarmonyOS】【FAQ】鸿蒙问题合集4
2022-07-30 17:43:00 【华为开发者论坛】
【问题描述1】
鸿蒙怎么实现跳转系统浏览器?浏览百度网页
【解决方案】
参考资料
【Harmony OS】【JAVA UI】abilitySlice和ability跳转方式
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
java版本
Intent intent= new Intent(); intent.setAction("android.intent.action.VIEW"); intent.setUri(Uri.parse("https://www.baidu.com/")); startAbility(intent);
ets或者js 版本
import featureAbility from '@ohos.ability.featureAbility';@[email protected] Index { public onclick(){ var str = { "want": { "deviceId": "", "bundleName": "", "abilityName": "", "uri": "https://www.baidu.com/", "action":"android.intent.action.VIEW", }, "abilityStartSetting": {} }; featureAbility.startAbility(str) .then((data) => { console.info('Operation successful. Data: ' + JSON.stringify(data)) }).catch((error) => { console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text('Hello World') .fontSize(50) .fontWeight(FontWeight.Bold) .onClick(this.onclick.bind(this)) } .width('100%') .height('100%') }}
【问题描述2】
鸿蒙怎么实现,调用TextField.getLineCount()获取行数闪退
【解决方案】
参考如下链接
此api从Api Version 7 开始支持
【问题描述3】
鸿蒙怎么使用getLineCount()
【解决方案】
代码如下
textField.setBindStateChangedListener(new Component.BindStateChangedListener() { @Override public void onComponentBoundToWindow(Component component) { int count1=textField.getLineCount(); Text mytext=findComponentById(ResourceTable.Id_mytext); mytext.setText("#####行数"+count1); } @Override public void onComponentUnboundFromWindow(Component component) { } });
欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh
边栏推荐
- 2022年杭电多校第2场 1001 Static Query on Tree(树链剖分+哈希表差分
- 分账系统二清解决方案如何助力电商平台合规经营?
- LayaBox---TypeScript---类型兼容性
- mysql刷脏的几种场景以及相关参数
- 华为无线设备配置Mesh业务
- C陷阱与缺陷 第7章 可移植性缺陷 7.3 整数的大小
- LayaBox---TypeScript---变量声明
- 首发!阿里技术大牛最新耗时半个月整理出最全MySQL性能优化和高可用架构技术宝典,直接封神!
- Mysql brush dirty several scenarios and related parameters
- 测试.net文字转语音模块System.Speech
猜你喜欢
随机推荐
What are the applications of X-rays?
This year..I sincerely recommend the professional engineer to upgrade to the book!
[Solved] The problem that Unity Hub fails to obtain a license or does not respond and cannot develop
leetcode-684:冗余连接
C陷阱与缺陷 第6章 预处理器 6.4 宏并不是类型定义
C陷阱与缺陷 第6章 预处理器 6.1 不能忽视宏定义中的空格
What is NDT equipment?
Ecplise执行C语言报错:cannot open output file xxx.exe: Permission denied
2022鹏城杯web
Kettle(二):连接SQL Server数据库
【网络工程】A、B、C、D、E类IP地址划分依据和特殊的IP地址
web服务通过用户访问请求判断设备来源
ARC在编译期和运行期做了什么
信息学奥赛一本通 1966:【14NOIP普及组】比例简化 | 洛谷 P2118 [NOIP2014 普及组] 比例简化
What ARC does at compile time and runtime
Google earth engine如何实现我们时间列表的排列和选取
Hangzhou electric school game 2 1001 2022 Static Query on Tree (Tree + hash table difference chain subdivision
千亿级、大规模:腾讯超大 Apache Pulsar 集群性能调优实践
数据库系统原理与应用教程(067)—— MySQL 练习题:操作题 82-89(十一):数据的增、删、改操作
LayaBox---TypeScript---函数