Android:任意层级树形控件(有效果图和Demo示例)
先上效果图:

1.创建treeview文件夹
2.treeview -> adapter -> SimpleTreeAdapter.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;import com.ybgc.acceptanceofconcealedwork.R;
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.Node;
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.TreeListViewAdapter;import java.util.List;public class SimpleTreeAdapter<T> extends TreeListViewAdapter<T> {// private int mCurrentItem = -1;private ViewHolder viewHolder = null;private Context mContext;public SimpleTreeAdapter(ListView mTree, Context context, List<T> datas,int defaultExpandLevel) throws IllegalArgumentException,IllegalAccessException {super(mTree, context, datas, defaultExpandLevel);mContext = context;}@Overridepublic View getConvertView(Node node, int position, View convertView, ViewGroup parent) {if (convertView == null) {convertView = mInflater.inflate(R.layout.list_item, parent, false);viewHolder = new ViewHolder();viewHolder.icon = convertView.findViewById(R.id.id_treenode_icon);viewHolder.label = convertView.findViewById(R.id.id_treenode_label);viewHolder.rlSelectItem = convertView.findViewById(R.id.rlSelectItem);convertView.setTag(viewHolder);} else {viewHolder = (ViewHolder) convertView.getTag();}if (node.getIcon() == -1) {viewHolder.icon.setVisibility(View.INVISIBLE);} else {viewHolder.icon.setVisibility(View.VISIBLE);viewHolder.icon.setImageResource(node.getIcon());}viewHolder.label.setText(node.getName());return convertView;}private final class ViewHolder {private ImageView icon;private TextView label;private RelativeLayout rlSelectItem;}
}
3.treeview -> treebean
3.1.treeview -> treebean -> Node.java
import java.util.ArrayList;
import java.util.List;public class Node
{private String id;/*** 根节点pId为0*/private String pId = "0";private String name;/*** 当前的级别*/private int level;/*** 是否展开*/private boolean isExpand = false;private int icon;/*** 下一级的子Node*/private List<Node> children = new ArrayList<Node>();/*** 父Node*/private Node parent;public Node(){}public Node(String id, String pId, String name){super();this.id = id;this.pId = pId;this.name = name;}public int getIcon(){return icon;}public void setIcon(int icon){this.icon = icon;}public String getId(){return id;}public void setId(String id){this.id = id;}public String getpId(){return pId;}public void setpId(String pId){this.pId = pId;}public String getName(){return name;}public void setName(String name){this.name = name;}public void setLevel(int level){this.level = level;}public boolean isExpand(){return isExpand;}public List<Node> getChildren(){return children;}public void setChildren(List<Node> children){this.children = children;}public Node getParent(){return parent;}public void setParent(Node parent){this.parent = parent;}/*** 是否为跟节点* * @return*/public boolean isRoot(){return parent == null;}/*** 判断父节点是否展开* * @return*/public boolean isParentExpand(){if (parent == null)return false;return parent.isExpand();}/*** 是否是叶子节点* * @return*/public boolean isLeaf(){return children.size() == 0;}/*** 获取level*/public int getLevel(){return parent == null ? 0 : parent.getLevel() + 1;}/*** 设置展开* * @param isExpand*/public void setExpand(boolean isExpand){this.isExpand = isExpand;if (!isExpand){for (Node node : children){node.setExpand(isExpand);}}}}
3.2.treeview -> treebean -> TreeHelper.java
import com.ybgc.acceptanceofconcealedwork.R;
import com.ybgc.acceptanceofconcealedwork.util.LogUtil;import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;public class TreeHelper {/*** 传入我们的普通bean,转化为我们排序后的Node** @param datas* @param defaultExpandLevel* @return* @throws IllegalArgumentException* @throws IllegalAccessException*/public static <T> List<Node> getSortedNodes(List<T> datas,int defaultExpandLevel) {List<Node> result = new ArrayList<Node>();try {// 将用户数据转化为List<Node>List<Node> nodes = convetData2Node(datas);// 拿到根节点List<Node> rootNodes = getRootNodes(nodes);// 排序以及设置Node间关系for (Node node : rootNodes) {addNode(result, node, defaultExpandLevel, 1);}} catch (Exception e) {LogUtil.e(e.toString());}return result;}/*** 过滤出所有可见的Node** @param nodes* @return*/public static List<Node> filterVisibleNode(List<Node> nodes) {List<Node> result = new ArrayList<Node>();try {for (Node node : nodes) {// 如果为跟节点,或者上层目录为展开状态if (node.isRoot() || node.isParentExpand()) {setNodeIcon(node);result.add(node);}}} catch (Exception e) {LogUtil.e(e.toString());}return result;}/*** 将我们的数据转化为树的节点** @param datas* @return* @throws NoSuchFieldException* @throws IllegalAccessException* @throws IllegalArgumentException*/private static <T> List<Node> convetData2Node(List<T> datas) {List<Node> nodes = new ArrayList<Node>();Node node = null;try {for (T t : datas) {String id = "-1";String pId = "-1";String label = null;Class<? extends Object> clazz = t.getClass();Field[] declaredFields = clazz.getDeclaredFields();for (Field f : declaredFields) {if (f.getAnnotation(TreeNodeId.class) != null) {f.setAccessible(true);id = String.valueOf(f.get(t));}if (f.getAnnotation(TreeNodePid.class) != null) {f.setAccessible(true);pId = String.valueOf(f.get(t));}if (f.getAnnotation(TreeNodeLabel.class) != null) {f.setAccessible(true);label = (String) f.get(t);}if (!id.equals("-1") && !pId.equals("-1") && label != null) {break;}}node = new Node(id, pId, label);nodes.add(node);}/*** 设置Node间,父子关系;让每两个节点都比较一次,即可设置其中的关系*/for (int i = 0; i < nodes.size(); i++) {Node n = nodes.get(i);for (int j = i + 1; j < nodes.size(); j++) {Node m = nodes.get(j);if (m.getpId().equals(n.getId())) {n.getChildren().add(m);m.setParent(n);} else if (m.getId().equals(n.getpId())) {m.getChildren().add(n);n.setParent(m);}}}// 设置图片for (Node n : nodes) {setNodeIcon(n);}} catch (Exception e) {LogUtil.e(e.toString());}return nodes;}private static List<Node> getRootNodes(List<Node> nodes) {List<Node> root = new ArrayList<Node>();try {for (Node node : nodes) {if (node.isRoot())root.add(node);}} catch (Exception e) {LogUtil.e(e.toString());}return root;}/*** 把一个节点上的所有的内容都挂上去*/private static void addNode(List<Node> nodes, Node node,int defaultExpandLeval, int currentLevel) {try {nodes.add(node);if (defaultExpandLeval >= currentLevel) {node.setExpand(true);}if (node.isLeaf())return;for (int i = 0; i < node.getChildren().size(); i++) {addNode(nodes, node.getChildren().get(i), defaultExpandLeval,currentLevel + 1);}} catch (Exception e) {LogUtil.e(e.toString());}}/*** 设置节点的图标** @param node*/private static void setNodeIcon(Node node) {try {if (node.getChildren().size() > 0 && node.isExpand()) {node.setIcon(R.mipmap.tree_ex);//设置展开状态图标} else if (node.getChildren().size() > 0 && !node.isExpand()) {node.setIcon(R.mipmap.tree_ec);//设置未展开状态图标} else {node.setIcon(-1);}} catch (Exception e) {LogUtil.e(e.toString());}}}
3.3.treeview -> treebean -> TreeListViewAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;import java.util.List;public abstract class TreeListViewAdapter<T> extends BaseAdapter
{protected Context mContext;/*** 存储所有可见的Node*/protected List<Node> mNodes;protected LayoutInflater mInflater;/*** 存储所有的Node*/protected List<Node> mAllNodes;/*** 点击的回调接口*/private OnTreeNodeClickListener onTreeNodeClickListener;public interface OnTreeNodeClickListener{void onClick(Node node, int position);}public void setOnTreeNodeClickListener(OnTreeNodeClickListener onTreeNodeClickListener){this.onTreeNodeClickListener = onTreeNodeClickListener;}/*** * @param mTree* @param context* @param datas* @param defaultExpandLevel* 默认展开几级树* @throws IllegalArgumentException* @throws IllegalAccessException*/public TreeListViewAdapter(ListView mTree, Context context, List<T> datas,int defaultExpandLevel) throws IllegalArgumentException,IllegalAccessException{mContext = context;/*** 对所有的Node进行排序*/mAllNodes = TreeHelper.getSortedNodes(datas, defaultExpandLevel);/*** 过滤出可见的Node*/mNodes = TreeHelper.filterVisibleNode(mAllNodes);mInflater = LayoutInflater.from(context);/*** 设置节点点击时,可以展开以及关闭;并且将ItemClick事件继续往外公布*/mTree.setOnItemClickListener(new OnItemClickListener(){@Overridepublic void onItemClick(AdapterView<?> parent, View view,int position, long id){expandOrCollapse(position);if (onTreeNodeClickListener != null){onTreeNodeClickListener.onClick(mNodes.get(position),position);}}});}/*** 相应ListView的点击事件 展开或关闭某节点* * @param position*/public void expandOrCollapse(int position){Node n = mNodes.get(position);if (n != null)// 排除传入参数错误异常{if (!n.isLeaf()){n.setExpand(!n.isExpand());mNodes = TreeHelper.filterVisibleNode(mAllNodes);notifyDataSetChanged();// 刷新视图}}}@Overridepublic int getCount(){return mNodes.size();}@Overridepublic Object getItem(int position){return mNodes.get(position);}@Overridepublic long getItemId(int position){return position;}@Overridepublic View getView(int position, View convertView, ViewGroup parent){Node node = mNodes.get(position);convertView = getConvertView(node, position, convertView, parent);// 设置内边距convertView.setPadding(node.getLevel() * 30, 3, 3, 3);return convertView;}public abstract View getConvertView(Node node, int position,View convertView, ViewGroup parent);}
3.4.treeview -> treebean -> TreeNodeId.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TreeNodeId
{
}
3.5.treeview -> treebean -> TreeNodeLabel.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TreeNodeLabel
{}
3.6.treeview -> treebean -> TreeNodePid.java
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface TreeNodePid
{}
4.treeview -> bean
4.1.treeview -> bean -> FileBean.java
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.TreeNodeAcode;
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.TreeNodeId;
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.TreeNodeLabel;
import com.ybgc.acceptanceofconcealedwork.divview.treeview.treebean.TreeNodePid;public class FileBean
{@TreeNodeIdprivate String id;@TreeNodePidprivate String parentId;@TreeNodeLabelprivate String name;private long length;private String desc;public FileBean(String id, String parentId, String name,String acode){super();this.id = id;this.parentId = parentId;this.name = name;}}
5.layout布局文件
5.1.activity_main.xml 主文件布局(ListView就是树形控件的载体)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><ListViewandroid:id="@+id/id_tree"android:layout_width="fill_parent"android:layout_height="fill_parent"android:divider="#aaa"android:dividerHeight="1px" ></ListView></RelativeLayout>
5.2.ListView 的子布局list_item.xml(树形控件的子布局,里面的图片就是用来展示树形控件打开状态和关闭状态的图片)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"android:minHeight="40dip" ><ImageViewandroid:id="@+id/id_treenode_icon"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_marginLeft="5dp"android:layout_marginRight="5dp"android:src="@drawable/tree_ec" /><TextViewandroid:id="@+id/id_treenode_label"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_toRightOf="@id/id_treenode_icon"android:text="@string/app_name"android:textSize="18dip" /></RelativeLayout>
6.上面树形控件代码已经完成,下面是页面中使用
import java.util.ArrayList;
import java.util.List;public class MainActivity extends AppCompatActivity {private List<FileBean> mDatas = new ArrayList<FileBean>();private ListView mTree;private TreeListViewAdapter mAdapter;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initDatas();mTree = findViewById(R.id.id_tree);try {//适配器参数:tree控件,上下文,数据源,默认展开层级mAdapter = new SimpleTreeAdapter<FileBean>(mTree, this, mData, 0);//初始化适配器mAdapter.setOnTreeNodeClickListener(new TreeListViewAdapter.OnTreeNodeClickListener() {//点击事件监听@Overridepublic void onClick(Node node, int position) {if (node.isLeaf()) {Toast.makeText(getApplicationContext(), node.getName(),Toast.LENGTH_SHORT).show();}}});} catch (Exception e) {e.printStackTrace();}mTree.setAdapter(mAdapter);//设置数据}/*** 初始化数据*/private void initData() {mDatas.add(new FileBean("1", "0", "文件管理系统"));mDatas.add(new FileBean("2", "1", "游戏"));mDatas.add(new FileBean("3", "1", "文档"));mDatas.add(new FileBean("4", "1", "程序"));mDatas.add(new FileBean("5", "2", "使命召唤"));mDatas.add(new FileBean("6", "2", "绝地求生"));mDatas.add(new FileBean("7", "4", "面向对象"));mDatas.add(new FileBean("8", "4", "非面向对象"));mDatas.add(new FileBean("9", "7", "C++"));mDatas.add(new FileBean("10", "7", "JAVA"));mDatas.add(new FileBean("11", "7", "Javascript"));mDatas.add(new FileBean("12", "8", "C"));mDatas.add(new FileBean("13", "3", "测试文档1"));mDatas.add(new FileBean("14", "3", "测试文档2"));}
}
以上就是自定义树形控件的所有代码,希望对大家的学习和工作有所帮助。
相关文章:
Android:任意层级树形控件(有效果图和Demo示例)
先上效果图: 1.创建treeview文件夹 2.treeview -> adapter -> SimpleTreeAdapter.java import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.ListView; i…...
C++ 容器全面剖析:掌握 STL 的奥秘,从入门到高效编程
引言 C 标准模板库(STL)提供了一组功能强大的容器类,用于存储和操作数据集合。不同的容器具有独特的特性和应用场景,因此选择合适的容器对于程序的性能和代码的可读性至关重要。对于刚接触 C 的开发者来说,了解这些容…...
C++---类型转换
文章目录 C的类型转换C的4种强制类型转换RTTI C的类型转换 类型转换 内置类型之间的转换 // a、内置类型之间 // 1、隐式类型转换 整形之间/整形和浮点数之间 // 2、显示类型的转换 指针和整形、指针之间 int main() {int i 1;// 隐式类型转换double d i;printf("%d…...
CSS基础学习练习题
编程题 1.为下面这段文字定义字体样式,要求字体类型指定多种、大小为14px、粗细为粗体、颜色为蓝色。 “有规划的人生叫蓝图,没规划的人生叫拼图。” 代码: <!DOCTYPE html> <html lang"en"> <head><me…...
TypeScript知识点总结和案例使用
TypeScript 是一种由微软开发的开源编程语言,它是 JavaScript 的超集,提供了静态类型检查和其他一些增强功能。以下是一些 TypeScript 的重要知识点总结: 1. 基本类型 TypeScript 支持多种基本数据类型,包括: numbe…...
解决BUG: Since 17.0, the “attrs“ and “states“ attributes are no longer used.
从Odoo 17.0开始,attrs和states属性不再使用,取而代之的是使用depends和domain属性来控制字段的可见性和其他行为。如果您想要在选择国家之后继续选择州,并且希望在选择了国家之后才显示州字段,您可以使用depends属性来实现这一点…...
单片机GPIO中断+定时器 实现模拟串口接收
单片机GPIO中断定时器 实现模拟串口接收 解决思路代码示例 解决思路 串口波特率9600bps,每个bit约为1000000us/9600104.16us; 定时器第一次定时时间设为52us即半个bit的时间,其目的是偏移半个bit时间,之后的每104us采样并读取1bit数据。使得…...
《深入理解 Spring MVC 工作流程》
一、Spring MVC 架构概述 Spring MVC 是一个基于 Java 的轻量级 Web 应用框架,它遵循了经典的 MVC(Model-View-Controller)设计模式,将请求、响应和业务逻辑分离,从而构建出灵活可维护的 Web 应用程序。 在 Spring MV…...
HTML简介
知识点一 HTML 什么是HTML? 超文本标记语言(HyperTextMarkup Language,简称HTML) 怎么学HTML? HTML 是一门标记语言,标记语言由一套标记标签组成,学习 HTML,其实就是学习标签 开发工具 编辑器: Pycha…...
Linux系统Centos设置开机默认root用户
目录 一. 教程 二. 部分第三方工具配置也无效 一. 教程 使用 Linux 安装Centos系统的小伙伴大概都知道,我们进入系统后,通常都是自己设置的普通用户身份,而不是 root 超级管理员用户,导致我们在操作文件夹时往往爆出没有权限&am…...
【网络安全 | 甲方建设】双/多因素认证、TOTP原理及实现
未经许可,不得转载。 文章目录 背景双因素、多因素认证双因素认证(2FA)多因素认证(MFA)TOTP实现TOTP生成流程TOTP算法TOTP代码示例(JS)Google Authenticator总结背景 在传统的在线银行系统中,用户通常只需输入用户名和密码就可以访问自己的账户。然而,如果密码不慎泄…...
Nuxt3 动态路由URL不更改的前提下参数更新,NuxtLink不刷新不跳转,生命周期无响应解决方案
Nuxt3 动态路由URL不更改的前提下参数更新,NuxtLink不刷新不跳转,生命周期无响应解决方案 首先说明一点,Nuxt3 的动态路由响应机制是根据 URL 是否更改,参数的更改并不会触发 Router 去更新页面,这在 Vue3 上同样存在…...
2024华为java面经
华为2024年Java招聘面试题目可能会涵盖Java基础知识、核心技术、框架与工具、项目经验以及算法与数据结构等多个方面。以下是考的内容。 一、Java基础知识 Java中有哪些基本数据类型? Java为什么能够跨平台运行? String是基本数据类型吗?能…...
2021 年 9 月青少年软编等考 C 语言三级真题解析
目录 T1. 课程冲突思路分析T2. 余数相同问题思路分析T3. 生成括号思路分析T4. 广义格雷码思路分析T5. 菲波那契数列思路分析T1. 课程冲突 小 A 修了 n n n 门课程,第 i i i 门课程是从第 a i a_i ai 天一直上到第 b i b_i bi 天。 定义两门课程的冲突程度为:有几天…...
深度解析FastDFS:构建高效分布式文件存储的实战指南(下)
接上篇:《深度解析FastDFS:构建高效分布式文件存储的实战指南(上)》 传送门: link 文章目录 六、常用命令七、FastDFS配置详解7.1 tracker配置文件7.2 tracker目录及文件结构7.3 storage配置文件7.4 storage服务器的目录结构和文件…...
Python学习29天
二分查找 # 定义函数冒泡排序法从大到小排列 def bbble_sort(list):# i控制排序次数for i in range(len(list) - 1):# j控制每次排序比较次数for j in range(len(list) - 1 - i):if list[j] < list[j 1]:list[j], list[j 1] list[j 1], list[j] # 定义二分查找函数 def…...
Soul App创始人张璐团队携多模态大模型参加GITEX GLOBAL,展现未来社交趋势
作为中东地区规模最大、最成功的计算机通讯及消费性电子产品展,GITEX GLOBAL一直颇受全球关注,于今年迎来了第44届盛会。自诞生以来,GITEX GLOBAL始终聚焦技术驱动的创新,吸引了许多科技巨头、创新企业及投资者的参与。Soul App作为中国较早将AI技术引入社交的企业,今年首次亮相…...
简单工厂模式、方法工厂模式
简单工厂模式(Simple Factory Pattern) 简单工厂模式的核心思想是通过一个工厂类,根据提供的参数来决定创建哪一个具体的产品类实例。 这个模式通常用于产品种类较少,且不经常变化的场景。 interface Product {void create(); }…...
【面试】前端vue项目架构详细描述
基于您提供的技术栈和要求,以下是前端项目的架构设计描述: 项目结构 • 入口文件: main.js 作为项目的入口文件,负责初始化 Vue 实例,并挂载到 DOM 上。 • 组件目录: components 目录包含项目的所有 Vue 组…...
BERT的中文问答系统32
我们需要在现有的代码基础上增加网络搜索功能,并在大模型无法提供满意答案时调用网络搜索。以下是完整的代码和文件结构说明,我们创建一个完整的项目结构,包括多个文件和目录。这个项目将包含以下部分: 主文件 (main.py)…...
R语言AI模型部署方案:精准离线运行详解
R语言AI模型部署方案:精准离线运行详解 一、项目概述 本文将构建一个完整的R语言AI部署解决方案,实现鸢尾花分类模型的训练、保存、离线部署和预测功能。核心特点: 100%离线运行能力自包含环境依赖生产级错误处理跨平台兼容性模型版本管理# 文件结构说明 Iris_AI_Deployme…...
前端倒计时误差!
提示:记录工作中遇到的需求及解决办法 文章目录 前言一、误差从何而来?二、五大解决方案1. 动态校准法(基础版)2. Web Worker 计时3. 服务器时间同步4. Performance API 高精度计时5. 页面可见性API优化三、生产环境最佳实践四、终极解决方案架构前言 前几天听说公司某个项…...
Cloudflare 从 Nginx 到 Pingora:性能、效率与安全的全面升级
在互联网的快速发展中,高性能、高效率和高安全性的网络服务成为了各大互联网基础设施提供商的核心追求。Cloudflare 作为全球领先的互联网安全和基础设施公司,近期做出了一个重大技术决策:弃用长期使用的 Nginx,转而采用其内部开发…...
如何在最短时间内提升打ctf(web)的水平?
刚刚刷完2遍 bugku 的 web 题,前来答题。 每个人对刷题理解是不同,有的人是看了writeup就等于刷了,有的人是收藏了writeup就等于刷了,有的人是跟着writeup做了一遍就等于刷了,还有的人是独立思考做了一遍就等于刷了。…...
ABAP设计模式之---“简单设计原则(Simple Design)”
“Simple Design”(简单设计)是软件开发中的一个重要理念,倡导以最简单的方式实现软件功能,以确保代码清晰易懂、易维护,并在项目需求变化时能够快速适应。 其核心目标是避免复杂和过度设计,遵循“让事情保…...
10-Oracle 23 ai Vector Search 概述和参数
一、Oracle AI Vector Search 概述 企业和个人都在尝试各种AI,使用客户端或是内部自己搭建集成大模型的终端,加速与大型语言模型(LLM)的结合,同时使用检索增强生成(Retrieval Augmented Generation &#…...
【Go语言基础【13】】函数、闭包、方法
文章目录 零、概述一、函数基础1、函数基础概念2、参数传递机制3、返回值特性3.1. 多返回值3.2. 命名返回值3.3. 错误处理 二、函数类型与高阶函数1. 函数类型定义2. 高阶函数(函数作为参数、返回值) 三、匿名函数与闭包1. 匿名函数(Lambda函…...
【分享】推荐一些办公小工具
1、PDF 在线转换 https://smallpdf.com/cn/pdf-tools 推荐理由:大部分的转换软件需要收费,要么功能不齐全,而开会员又用不了几次浪费钱,借用别人的又不安全。 这个网站它不需要登录或下载安装。而且提供的免费功能就能满足日常…...
深度学习水论文:mamba+图像增强
🧀当前视觉领域对高效长序列建模需求激增,对Mamba图像增强这方向的研究自然也逐渐火热。原因在于其高效长程建模,以及动态计算优势,在图像质量提升和细节恢复方面有难以替代的作用。 🧀因此短时间内,就有不…...
C# 表达式和运算符(求值顺序)
求值顺序 表达式可以由许多嵌套的子表达式构成。子表达式的求值顺序可以使表达式的最终值发生 变化。 例如,已知表达式3*52,依照子表达式的求值顺序,有两种可能的结果,如图9-3所示。 如果乘法先执行,结果是17。如果5…...
