日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS創(chuàng)建另一個(gè)頁面

創(chuàng)建 Feature Ability

石阡ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

  1. 在“Project”窗口,打開“entry > src > main > java”,右鍵點(diǎn)擊“com.example.myapplication”文件夾,選擇“New > Ability > Empty Feature Ability(Java)”。
  1. 配置 Ability 時(shí),將“Page Name”設(shè)置為“SecondAbility”,點(diǎn)擊“Finish”。創(chuàng)建完成后,可以看到新增了“SecondAbility”和“SecondAbilitySlice”文件。

代碼編寫界面

在上一節(jié)中,我們用 XML 的方式編寫了一個(gè)包含文本和按鈕的頁面。為了幫助開發(fā)者熟悉在代碼中創(chuàng)建布局的方式,接下來我們使用此方式編寫第二個(gè)頁面。

打開 “SecondAbilitySlice.java”文件,添加一個(gè)文本,示例代碼如下:

package com.example.myapplication.slice;

 
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.DependentLayout.LayoutConfig;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

 
import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT;
import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_CONTENT;

 
public class SecondAbilitySlice extends AbilitySlice {

 
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 聲明布局
        DependentLayout myLayout = new DependentLayout(this);
        // 設(shè)置布局大小
        myLayout.setWidth(MATCH_PARENT);
        myLayout.setHeight(MATCH_PARENT);
        ShapeElement element = new ShapeElement();
        element.setRgbColor(new RgbColor(0, 0, 0));
        myLayout.setBackground(element);

 
        // 創(chuàng)建一個(gè)文本
        Text text = new Text(this);
        text.setText("Nice to meet you.");
        text.setWidth(MATCH_PARENT);
        text.setTextSize(55);
        text.setTextColor(Color.WHITE);
        // 設(shè)置文本的布局
        DependentLayout.LayoutConfig textConfig = new DependentLayout.LayoutConfig(MATCH_CONTENT,MATCH_CONTENT);
        textConfig.addRule(LayoutConfig.CENTER_IN_PARENT);
        text.setLayoutConfig(textConfig);
        myLayout.addComponent(text);

 
        super.setUIContent(myLayout);
    }

 
    @Override
    public void onActive() {
        super.onActive();
    }

 
    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}

當(dāng)前文章:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OS創(chuàng)建另一個(gè)頁面
新聞來源:http://www.5511xx.com/article/ccssccp.html