首页 > 其他分享 >江鸟中原——鸿蒙App应用-《校园通》

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

时间:2023-12-10 17:32:41浏览次数:25  
标签:江鸟 鸿蒙 parent text App iv width ohos height

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

      《校园通》软件很多系统中都有,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

    

标签:江鸟,鸿蒙,parent,text,App,iv,width,ohos,height
From: https://blog.51cto.com/u_16426441/8762158

相关文章

  • vue3学习之createApp(App).mount('#app')
    装了vue-cli之后,新建个项目跑起来了,碰上个没理解的问题,不知道createApp(App).mount('#app')挂载的这个id=“app”从哪冒出来的 用命令创建出来的项目,components/HelloWorld.vue,App.vue,main.js中都没有估摸着得是底层的,网上找一圈,各路大神基本是一句带过,可能是太简单了,没......
  • 【UniApp】-uni-app-OptionAPI应用生命周期和页面生命周期
    前言好,经过上个章节的介绍完毕之后,了解了一下uni-app-修改组件主题和样式那么了解完了uni-app-修改组件主题和样式之后,这篇文章来给大家介绍一下uni-app-OptionAPI应用生命周期和页面生命周期首先不管三七二十一,先来新建一个项目搭建演示环境创建一个全新的项目:然后在......
  • 『江鸟中原』基于鸿蒙的抽奖小程序
    通过对鸿蒙的学习,我做了一个基于鸿蒙开发的小项目。中原工学院RB软工移211班王梦茹202119144101案例介绍开始时间,点击抽奖,Web页面的抽奖转盘会开始转动,结束抽奖后,原生页面会弹出一个提示弹窗,这个页面就涉及到Web页面和原生页面的双向交互具体实现步骤以上就是这个案例的开发流程,......
  • ApplicationContextInitializer在Spring容器执行refresh之前执行
    ApplicationContextInitializer用于在刷新Spring容器之前的回调接口。ApplicationContextInitializer是Spring框架原有的概念,这个类的主要目的就是在ConfigurableApplicationContext类型(或者子类型)的ApplicationContext进行刷新refresh之前,允许我们对ConfigurableApplicatio......
  • 京东App秒杀抢购流程接口分析(基于pypp技术)
    App数据抓包必需工具必需工具:小米手机,Charles,HttpCanary从2022年2月后,京东只限于从app发起抢购,所以,网上的很多工具已经无效了。只能分析app端的底层协议和流程。github地址:https://github.com/geeeeeeeek/jd_mt通过抓包可以发现,整个抢购流程分为七个步骤,如下:第一步是genToke......
  • uni-app使用夜神模拟器调试
    使用夜神模拟器调试1.配置环境变量复制adb.exe所在文件目录的路径,G:\HBuilderX\plugins\launcher\tools\adbs,配置到系统环境变量path中。2.配置HbuilderX打开模拟器端口设置界面夜神模拟器adb路径为D:\ProgramFiles\Nox\bin\adb.exe,夜神模拟器端口为620013.测试......
  • uni-app开发记录
    目录uni-app目录结构uni-app中的事件uni-app项目中@符号文件路径不提示uni-app中的组件通信页面通信组件间通信节点操作定义全局scss变量APP相关解决uniapp编译到APP出现页面抖动与滑动条tabbar添加一个位于中间的按钮uni.pageScrollTo滚动问题uni-app目录结构静态资源只能存......
  • ApplicationContext is unlikely to start due to a @ComponentScan of the default p
    springboot警告:ApplicationContextisunlikelytostartduetoa@ComponentScanofthedefaultpackage解决办法:1、一般发出这个警告的原因是你把启动类直接放在的src目录下面。2、你需要在src目录下面再建一个包,然后把启动类放到下面。3、或者你错将启动类放到java文件中了......
  • Mybatis使用generator逆向工程生成器生成entity、mapper、.xml模版类
    前言今天将表建好了,但是一个一个的建实体类、Mapper接口、Mapper.xml文件就十分的麻烦,所以我就想到了MyBatis逆向,今天就操作一把!这里我们采用maven来进行操作。一、新建generatorConfig.xml文件首先建好表,在你的项目的resource文件中新建generatorConfig.xml文件。代码如下:<?xmlv......
  • 【UniApp】-uni-app-扩展组件
    前言好,经过上个章节的介绍完毕之后,了解了一下uni-app-内置组件那么了解完了uni-app-内置组件之后,这篇文章来给大家介绍一下UniApp中的扩展组件首先不管三七二十一,先来新建一个项目搭建演示环境创建一个全新的项目:然后在配置一下,微信小程序的AppId,直接去之前的项目中......