MainAbilitySlice.java
”文件,重写onStart()
方法添加按钮的响应逻辑,实现点击按钮跳转到下一页,示例代码如下: package com.example.myapplication.slice;
import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.*;
public class MainAbilitySlice extends AbilitySlice {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_main_layout);
Button button = (Button) findComponentById(ResourceTable.Id_button);
if (button != null) {
// 为按钮设置点击回调
button.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component component) {
Intent secondIntent = new Intent();
// 指定待启动FA的bundleName和abilityName
Operation operation = new Intent.OperationBuilder()
.withDeviceId("")
.withBundleName("com.example.myapplication")
.withAbilityName("com.example.myapplication.SecondAbility")
.build();
secondIntent.setOperation(operation);
startAbility(secondIntent); // 通过AbilitySlice的startAbility接口实现启动另一个页面
}
});
}
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
}
ByteArrayInputStreamjava.lang.Object |---java.io.InputStream |---|---java.io.ByteArrayInputStreampublic class ByteArrayI...
BaseFileDescriptorjava.lang.Object |---ohos.global.resource.BaseFileDescriptorpublic abstract class BaseFileDescriptorex...
ResultSetHookpublic interface ResultSetHook提供创建结果集的方法。此类允许您自定义结果集。Since:1方法总结修饰符和类型方法...
wx.cloud.database获取数据库的引用方法签名如下:function database(options?: object): Database方法接受一个可选对象参数 opt...
db.serverDate构造一个服务端时间的引用。可用于查询条件、更新字段值或新增记录时的字段值。方法签名如下:function serverDate...
Database.RegExp构造正则表达式,仅需在普通 js 正则表达式无法满足的情况下使用options 参数说明options支持 i, m, s 这三个 fl...
令面板,我们在之前的学习过程中已经多次使用了。命令面板是一个非常特殊的 UI 组件,假如说你从来没有用过 VS Code 或者 Sublim...