0
点赞
收藏
分享

微信扫一扫

江鸟中原——鸿蒙App应用-《校园通》

        我是中原工学院软工金学生黄晓雨。以下是我的实践报告。

      《校园通》软件很多系统中都有,android,ios,平板电脑等,该软件主要用于学校里的环境,学生,老师之间的沟通,方便学生的行动。

实现思路:

创建一个Java语言的鸿蒙项目

创建主界面,包含:学校生活,出行指南,游玩南昌,号码百事通等四大模块

学校生活:校区平面图,校园风景,学生指南,返回等功能

游玩南昌:西山万寿宫,梅岭等风景点简介

号码百事通:学生可查询学校的院系信息,教师信息,订餐信息等

出行指南:这里调用高德地图开发者平台的第三方类库,完成我的位置,线路查询,位置查询等功能

2. 搭建HarmonyOS环境

我们首先需要完成HarmonyOS开发环境搭建,可参照如下步骤进行。


安装DevEco Studio,详情请参考下载和安装软件。

设置DevEco Studio开发环境,DevEco Studio开发环境依赖于网络环境,需要连接上网络才能确保工具的正常使用,可以根据如下两种情况来配置开发环境:

1.如果可以直接访问Internet,只需进行下载HarmonyOS SDK操作。

2.如果网络不能直接访问Internet,需要通过代理服务器才可以访问,请参考配置开发环境。

创建MainAbilitySlice的类,并继承AbilitySlice,实现onStart方法加载布局文件。

package com.example.campusproject.slice;

 

import com.example.campusproject.ResourceTable;

import ohos.aafwk.ability.AbilitySlice;

import ohos.aafwk.content.Intent;

import ohos.agp.components.Image;

 

public

class MainAbilitySlice extends AbilitySlice {

   private Image iv_lt,iv_rt,iv_lb,iv_rb;

   @Override

   public void onStart(Intent intent) {

       super.onStart(intent);

       super.setUIContent(ResourceTable.Layout_ability_main);

       iv_lb= (Image) this.findComponentById(ResourceTable.Id_iv_lb);

       iv_lt= (Image) this.findComponentById(ResourceTable.Id_iv_lt);

       iv_rt= (Image) this.findComponentById(ResourceTable.Id_iv_rt);

       iv_rb= (Image) this.findComponentById(ResourceTable.Id_iv_rb);

       //学校生活

       iv_lt.setClickedListener(listener->present(new XXSHAbilitySlice(),

               new Intent()));

       //出行指南

       iv_rt.setClickedListener(listener->present(new CXZNAbilitySlice(),new Intent()));

       //游玩南昌

       iv_lb.setClickedListener(listener->present(new YWNNAbilitySlice(),new Intent()));

       //号码百事通

       iv_rb.setClickedListener(listener->present(new HMBSTAbilitySlice(),new Intent()));

   }

 

   @Override

   public void onActive() {

       super.onActive();

   }

 

   @Override

   public void onForeground(Intent intent) {

       super.onForeground(intent);

   }

}

在resources->base->layout下创建ability_main.xml布局文件

<?xml version="1.0" encoding="utf-8"?>

<DirectionalLayout

   xmlns:ohos="http://schemas.huawei.com/res/ohos"

   ohos:height="match_parent"

   ohos:width="match_parent"

   ohos:background_element="$media:bg"

   ohos:orientation="vertical">

 

  <DirectionalLayout

      ohos:height="100fp"

      ohos:weight="1"

      ohos:width="match_parent"

      ohos:orientation="vertical"

      ohos:background_element="#88ffffff"

      ohos:alignment="center">

      <Text

          ohos:height="match_content"

          ohos:width="match_parent"

          ohos:text_alignment="center"

          ohos:text="华为开发者大学"

          ohos:text_color="#000"

          ohos:text_size="25fp"/>

      <Text

          ohos:height="match_content"

          ohos:width="match_parent"

          ohos:text_alignment="center"

          ohos:text="Huawei Developer University"

          ohos:text_color="#000"

          ohos:text_size="18fp"/>

 

  </DirectionalLayout>

 

   <DependentLayout

       ohos:weight="3"

       ohos:margin="30fp"

       ohos:height="match_content"

       ohos:width="match_parent">

 

       <Image

           ohos:height="80fp"

           ohos:width="80fp"

           ohos:center_in_parent="true"

           ohos:scale_mode="stretch"

           ohos:image_src="$media:hw"/>

 

       <Image

           ohos:id="$+id:iv_lt"

           ohos:align_parent_left="true"

           ohos:height="60fp"

           ohos:width="100fp"

           ohos:scale_mode="stretch"

           ohos:image_src="$media:xuexiaoshenghuo"/>

 

       <Image

           ohos:id="$+id:iv_rt"

           ohos:align_parent_right="true"

           ohos:height="60fp"

           ohos:width="100fp"

           ohos:scale_mode="stretch"

           ohos:image_src="$media:chuxingzhinan"/>

       <Image

           ohos:id="$+id:iv_lb"

           ohos:align_parent_left="true"

           ohos:align_parent_bottom="true"

           ohos:height="60fp"

           ohos:width="100fp"

           ohos:scale_mode="stretch"

           ohos:image_src="$media:youwannanchang"/>

       <Image

           ohos:id="$+id:iv_rb"

           ohos:align_parent_right="true"

           ohos:align_parent_bottom="true"

           ohos:height="60fp"

           ohos:width="100fp"

           ohos:scale_mode="stretch"

           ohos:image_src="$media:haomabaishitong"/>

   </DependentLayout>

 

   <Text

       ohos:height="match_content"

       ohos:width="match_parent"

       ohos:text="构建万物互联的智能世界"

       ohos:text_color="#000"

       ohos:text_size="25fp"

       ohos:text_alignment="center"

       ohos:weight="2"/>

 

 

</DirectionalLayout>

效果展示

江鸟中原——鸿蒙App应用-《校园通》_Image

    

举报

相关推荐

0 条评论