<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          HarmonyOS學(xué)習(xí)路之開發(fā)基礎(chǔ)—快速入門(實現(xiàn)頁面跳轉(zhuǎn))

          共 1689字,需瀏覽 4分鐘

           ·

          2021-07-01 22:05

          點擊上方藍色字體,關(guān)注我們


          1


          實現(xiàn)頁面跳轉(zhuǎn)


          1、打開第一個頁面的“MainAbilitySlice.java”文件,添加按鈕的響應(yīng)邏輯,實現(xiàn)點擊按鈕跳轉(zhuǎn)到下一頁,示例代碼如下:


          import com.example.firstdemo.ResourceTable;
          import ohos.aafwk.ability.AbilitySlice;
          import ohos.aafwk.content.Intent;
          import ohos.agp.components.Button;

          public class MainAbilitySlice extends AbilitySlice {
              @Override
              public void onStart(Intent intent) {
                  super.onStart(intent);
                  super.setUIContent(ResourceTable.Layout_ability_main);
                  Button button = (Button) findComponentById(ResourceTable.Id_button);
                  // 點擊按鈕跳轉(zhuǎn)至第二個頁面
                  button.setClickedListener(listener -> present(new SecondAbilitySlice(), new Intent()));
              }

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

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


          2、再次運行項目,效果如下圖所示:



          3、通過點擊“Next”即可進入下一個界面且可實現(xiàn)界面跳轉(zhuǎn)的相關(guān)功能。


          往期推薦



          點擊閱讀原文,更精彩~
          瀏覽 71
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产精品久久久久久久搜平安片 | 亚洲第一色站 | 精品国产三级片 | 偷拍视频青青草 | 国产欧美日韩在线 |