首页 文章 精选 留言 我的

精选列表

搜索[c 17],共10016篇文章
优秀的个人博客,低调大师

自学鸿蒙应用开发(17)- TabList和Tab

本文介绍在鸿蒙应用中TabList和TabList.Tab组件的基本用法。 查看视频 准备TabList页面布局 在layout目录下创建TabList布局,将其命名为ability_tablist.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:orientation="vertical"> <TabList ohos:id="$+id:tab_list" ohos:background_element="#FFFF7F" ohos:top_margin="10vp" ohos:tab_margin="24vp" ohos:tab_length="140vp" ohos:text_size="20fp" ohos:height="36vp" ohos:width="match_parent" ohos:layout_alignment="center" ohos:orientation="horizontal" ohos:text_alignment="center" ohos:normal_text_color="#999999" ohos:selected_text_color="#000000" ohos:selected_tab_indicator_color="#000000" ohos:selected_tab_indicator_height="2vp"/> <DirectionalLayout ohos:id="$+id:tab_container" ohos:height="match_parent" ohos:width="match_parent"> </DirectionalLayout></DirectionalLayout> 布局代码中第7行~第22行的用于生成TabList组件,定义了TabList的基本属性;第23行~第27行用于生成Tab页面的容器,目前还没有具体内容,稍后有具体代码生成。 准备Image页面 Image页面主要包含一个Image文件和简单的文字表示: <?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:orientation="vertical"> <Component ohos:height="0vp" ohos:weight="3" ohos:width="match_parent" /> <DirectionalLayout xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:height="match_content" ohos:width="match_content" ohos:layout_alignment="center" ohos:orientation="vertical"> <Image ohos:id="$+id:image" ohos:width="match_content" ohos:height="match_content" ohos:layout_alignment="center" ohos:image_src="$media:DevEco" /> <Component ohos:height="20vp" ohos:width="match_parent" /> <Text ohos:id="$+id:text_helloworld" ohos:height="match_content" ohos:width="match_content" ohos:layout_alignment="horizontal_center" ohos:text="Image Tab" ohos:text_color="#007F00" ohos:text_size="100" /> </DirectionalLayout> <Component ohos:height="0vp" ohos:weight="5" ohos:width="match_parent" /></DirectionalLayout> 准备Video页面 Video页面包含一个动画,稍微复杂一些。首先是页面本身: <?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:orientation="vertical"> <Component ohos:height="0vp" ohos:weight="3" ohos:width="match_parent" /> <DirectionalLayout xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:height="match_content" ohos:width="match_content" ohos:layout_alignment="center" ohos:orientation="vertical"> <Component ohos:id="$+id:video_area" ohos:height="300vp" ohos:width="300vp" /> <Component ohos:height="20vp" ohos:width="match_parent" /> <Text ohos:id="$+id:text_helloworld" ohos:height="match_content" ohos:width="match_content" ohos:layout_alignment="horizontal_center" ohos:text="Video Tab" ohos:text_color="#0000FF" ohos:text_size="100" /> </DirectionalLayout> <Component ohos:height="0vp" ohos:weight="5" ohos:width="match_parent" /></DirectionalLayout> 这个文件和Image页面区别不大,只是在用Component组件代替了Image组件。而动画的实际内容则是由graphic目录中的animation_element.xml文件决定: <?xml version="1.0" encoding="utf-8"?><animation-list xmlns:ohos="http://schemas.huawei.com/res/ohos" ohos:oneshot="false"> <item ohos:element="$media:video01" ohos:duration="100"/> <item ohos:element="$media:video02" ohos:duration="100"/> <item ohos:element="$media:video03" ohos:duration="100"/> <item ohos:element="$media:video04" ohos:duration="100"/> <item ohos:element="$media:video05" ohos:duration="100"/> <item ohos:element="$media:video06" ohos:duration="100"/> <item ohos:element="$media:video07" ohos:duration="100"/> <item ohos:element="$media:video08" ohos:duration="100"/> <item ohos:element="$media:video09" ohos:duration="100"/> <item ohos:element="$media:video10" ohos:duration="100"/> <item ohos:element="$media:video11" ohos:duration="100"/></animation-list> 生成TabList画面 TabList的每个Tab页面需要由代码生成,具体参见下面的页面类: package com.example.helloharmony.slice; import com.example.helloharmony.ResourceTable;import ohos.aafwk.ability.AbilitySlice;import ohos.aafwk.content.Intent;import ohos.agp.components.*;import ohos.agp.components.element.FrameAnimationElement; import java.io.Console; public class TablistAbilitySlice extends AbilitySlice { private Component imageContent; private Component videoContent; private FrameAnimationElement frameAnimationElement; @Override public void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_tablist); TabList tabList = (TabList) findComponentById(ResourceTable.Id_tab_list); tabList.setTabLength(200); // 设置Tab的宽度 tabList.setTabMargin(26); // 设置两个Tab之间的间距 TabList.Tab tab1 = tabList.new Tab(getContext()); tab1.setText("Image"); tabList.addTab(tab1); TabList.Tab tab2 = tabList.new Tab(getContext()); tab2.setText("Video"); tabList.addTab(tab2); AbilitySlice slice = this; tabList.addTabSelectedListener(new TabList.TabSelectedListener() { @Override public void onSelected(TabList.Tab tab) { ComponentContainer container = (ComponentContainer) findComponentById(ResourceTable.Id_tab_container); if(tab.getText().equals("Image")) { imageContent = LayoutScatter.getInstance(slice).parse(ResourceTable.Layout_iamge_tab, null, false); container.addComponent(imageContent); } else { videoContent = LayoutScatter.getInstance(slice).parse(ResourceTable.Layout_video_tab, null, false); frameAnimationElement = new FrameAnimationElement(slice.getContext(), ResourceTable.Graphic_animation_element); Component videoArea = videoContent.findComponentById(ResourceTable.Id_video_area); videoArea.setBackground(frameAnimationElement); frameAnimationElement.start(); container.addComponent(videoContent); } } @Override public void onUnselected(TabList.Tab tab) { if(tab.getText().equals("Video")) { frameAnimationElement.start(); } ComponentContainer container = (ComponentContainer) findComponentById(ResourceTable.Id_tab_container); container.removeAllComponents(); } @Override public void onReselected(TabList.Tab tab) { ComponentContainer container = (ComponentContainer) findComponentById(ResourceTable.Id_tab_container); if(tab.getText().equals("Image")) { container.addComponent(imageContent); } else { frameAnimationElement.start(); container.addComponent(videoContent); } } }); //最开始选选择tab1 tabList.selectTab(tab1); } @Override public void onActive() { super.onActive(); } @Override public void onForeground(Intent intent) { super.onForeground(intent); }} 代码第22行~第27行分别生成了Image和Video两个Tab页。 第29行~第69行是为TabList的各种事件提供响应。需要响应的处理主要有Tab页选择,Tab页取消选择和Tab重新选择。代码中根据当前选中的Tab页面生成或选择不同的组件。 参考文档 TabList和Tab组件 https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ui-java-component-tablist-tab-0000001062229749 TabList类 https://developer.harmonyos.com/cn/docs/documentation/doc-references/tablist-0000001054238721 Tab List.Tab类 https://developer.harmonyos.com/cn/docs/documentation/doc-references/tablist_tab-0000001054678691 动画开发指导 https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ui-java-animation-0000000000580278 新书介绍 《实战Python设计模式》是作者最近出版的Python编程书籍,拜托多多关注! 本书利用Python 的标准GUI 工具包tkinter,通过可执行的示例对23 个设计模式逐个进行说明。这样一方面可以使读者了解真实的软件开发工作中每个设计模式的运用场景和想要解决的问题;另一方面通过对这些问题的解决过程进行说明,让读者明白在编写代码时如何判断使用设计模式的利弊,并合理运用设计模式。 对设计模式感兴趣而且希望随学随用的读者通过本书可以快速跨越从理解到运用的门槛;希望学习Python GUI 编程的读者可以将本书中的示例作为设计和开发的参考;使用Python 语言进行图像分析、数据处理工作的读者可以直接以本书中的示例为基础,迅速构建自己的系统架构。 原文链接:https://developer.huawei.com/consumer/cn/forum/topic/0201551132050440304?fid=0101303901040230869 原作者:面向对象思考

优秀的个人博客,低调大师

突破Java面试(17)-ElasticSearch的部署架构

1 面试题 ES集群部署架构如何 每个索引的数据量大概多少 每个索引大概有多少分片 2 考点分析 问你生产环境咋部署的,说白了,没啥技术含量,就是看你有没有在真正的生产环境里做过ES! 有些同学可能没在生产环境做过,没在线上部署过ES集群,也没实际玩过,也没往ES集群里面导入过几千万甚至是几亿的数据量,可能你就不太清楚这里面的一些生产项目中的细节 如果你是自己就玩过demo,没碰过真实的ES集群,那你可能此时会懵,但是别怕!你一定要云淡风轻的回答,表示你确实干过ES! 3 详解 如果你确实干过ES,那你肯定了解你们生产es集群的实际情况,部署了几台机器?有多少个索引?每个索引有多大数据量?每个索引给了多少个分片?你肯定知道! 但是如果你确实没干过,也别虚,我给你说一个基本的版本,你到时候就简单说一下就好了 ES生产集群我们部署了5台机器,每台机器是6核

优秀的个人博客,低调大师

网站前端和后台性能优化17

后加载组件 (Post-load Components) tag:content 你可以仔细端详下你的页面然后自问:“什么是在页面初始化时必须的?”那么其余的内容和组件可以放在后面。 JavaScript是理想的用来分割onload事件之前和之后的选择。例如你有执行拖放、下拉和动画的JavaScript代码和菜单,它们可以稍后加载,因为用户在初始呈现之后才会在页面上拖动元素。其他的可以被后加载的地方包括隐藏的内容(当用户做某项操作才会展现的内容)和被折叠的图片。 可以帮助你的工具有: YUI Image Loader能帮助你延缓加载折叠的图片,而且YUI Get utility 能够很简单的包装运行中的JS和CSS。比如,打开Firebug的网络选项卡去查看Yahoo! Home Page。 当性能指标和其它网站开发的好的实践一致时是不错的。渐进增强的观念告诉我们当支持JavaScript时,会提高用户体验,但你必须确保在没有JavaScript时页面也能工作。所以当你确保页面工作正常时,你会通过延后加载的那些更花哨的脚本比如拖放和动画,来增强你的页面。

优秀的个人博客,低调大师

降SpringAI阿里第17掌-羝羊触藩-观星治理

我是老李。前几年做后端和运维,最怕的不是事故本身,是事故发生后群里那句「你再复现一下」。能复现的问题是好问题,不能复现的问题才是生产问题。这两年我把精力压在 Spring AI Alibaba 上,从第1掌的选型到第16掌把数字人立成一个可启动的 Spring Boot 服务,一路走来最大的感受是:Agent 系统的复杂度不在「写出来」,在「出问题之后你还认不认得它」。

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册