当前位置: 首页 > news >正文

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示例)

先上效果图&#xff1a; 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 标准模板库&#xff08;STL&#xff09;提供了一组功能强大的容器类&#xff0c;用于存储和操作数据集合。不同的容器具有独特的特性和应用场景&#xff0c;因此选择合适的容器对于程序的性能和代码的可读性至关重要。对于刚接触 C 的开发者来说&#xff0c;了解这些容…...

C++---类型转换

文章目录 C的类型转换C的4种强制类型转换RTTI C的类型转换 类型转换 内置类型之间的转换 // a、内置类型之间 // 1、隐式类型转换 整形之间/整形和浮点数之间 // 2、显示类型的转换 指针和整形、指针之间 int main() {int i 1;// 隐式类型转换double d i;printf("%d…...

CSS基础学习练习题

编程题 1.为下面这段文字定义字体样式&#xff0c;要求字体类型指定多种、大小为14px、粗细为粗体、颜色为蓝色。 “有规划的人生叫蓝图&#xff0c;没规划的人生叫拼图。​” 代码&#xff1a; <!DOCTYPE html> <html lang"en"> <head><me…...

TypeScript知识点总结和案例使用

TypeScript 是一种由微软开发的开源编程语言&#xff0c;它是 JavaScript 的超集&#xff0c;提供了静态类型检查和其他一些增强功能。以下是一些 TypeScript 的重要知识点总结&#xff1a; 1. 基本类型 TypeScript 支持多种基本数据类型&#xff0c;包括&#xff1a; numbe…...

解决BUG: Since 17.0, the “attrs“ and “states“ attributes are no longer used.

从Odoo 17.0开始&#xff0c;attrs和states属性不再使用&#xff0c;取而代之的是使用depends和domain属性来控制字段的可见性和其他行为。如果您想要在选择国家之后继续选择州&#xff0c;并且希望在选择了国家之后才显示州字段&#xff0c;您可以使用depends属性来实现这一点…...

单片机GPIO中断+定时器 实现模拟串口接收

单片机GPIO中断定时器 实现模拟串口接收 解决思路代码示例 解决思路 串口波特率9600bps,每个bit约为1000000us/9600104.16us&#xff1b; 定时器第一次定时时间设为52us即半个bit的时间&#xff0c;其目的是偏移半个bit时间&#xff0c;之后的每104us采样并读取1bit数据。使得…...

《深入理解 Spring MVC 工作流程》

一、Spring MVC 架构概述 Spring MVC 是一个基于 Java 的轻量级 Web 应用框架&#xff0c;它遵循了经典的 MVC&#xff08;Model-View-Controller&#xff09;设计模式&#xff0c;将请求、响应和业务逻辑分离&#xff0c;从而构建出灵活可维护的 Web 应用程序。 在 Spring MV…...

HTML简介

知识点一 HTML 什么是HTML&#xff1f; 超文本标记语言(HyperTextMarkup Language&#xff0c;简称HTML) 怎么学HTML&#xff1f; HTML 是一门标记语言&#xff0c;标记语言由一套标记标签组成&#xff0c;学习 HTML&#xff0c;其实就是学习标签 开发工具 编辑器: Pycha…...

Linux系统Centos设置开机默认root用户

目录 一. 教程 二. 部分第三方工具配置也无效 一. 教程 使用 Linux 安装Centos系统的小伙伴大概都知道&#xff0c;我们进入系统后&#xff0c;通常都是自己设置的普通用户身份&#xff0c;而不是 root 超级管理员用户&#xff0c;导致我们在操作文件夹时往往爆出没有权限&am…...

【网络安全 | 甲方建设】双/多因素认证、TOTP原理及实现

未经许可,不得转载。 文章目录 背景双因素、多因素认证双因素认证(2FA)多因素认证(MFA)TOTP实现TOTP生成流程TOTP算法TOTP代码示例(JS)Google Authenticator总结背景 在传统的在线银行系统中,用户通常只需输入用户名和密码就可以访问自己的账户。然而,如果密码不慎泄…...

Nuxt3 动态路由URL不更改的前提下参数更新,NuxtLink不刷新不跳转,生命周期无响应解决方案

Nuxt3 动态路由URL不更改的前提下参数更新&#xff0c;NuxtLink不刷新不跳转&#xff0c;生命周期无响应解决方案 首先说明一点&#xff0c;Nuxt3 的动态路由响应机制是根据 URL 是否更改&#xff0c;参数的更改并不会触发 Router 去更新页面&#xff0c;这在 Vue3 上同样存在…...

2024华为java面经

华为2024年Java招聘面试题目可能会涵盖Java基础知识、核心技术、框架与工具、项目经验以及算法与数据结构等多个方面。以下是考的内容。 一、Java基础知识 Java中有哪些基本数据类型&#xff1f; Java为什么能够跨平台运行&#xff1f; String是基本数据类型吗&#xff1f;能…...

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:构建高效分布式文件存储的实战指南(下)

接上篇&#xff1a;《深度解析FastDFS&#xff1a;构建高效分布式文件存储的实战指南&#xff08;上&#xff09;》 传送门: 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技术引入社交的企业,今年首次亮相…...

简单工厂模式、方法工厂模式

简单工厂模式&#xff08;Simple Factory Pattern&#xff09; 简单工厂模式的核心思想是通过一个工厂类&#xff0c;根据提供的参数来决定创建哪一个具体的产品类实例。 这个模式通常用于产品种类较少&#xff0c;且不经常变化的场景。 interface Product {void create(); }…...

【面试】前端vue项目架构详细描述

基于您提供的技术栈和要求&#xff0c;以下是前端项目的架构设计描述&#xff1a; 项目结构 • 入口文件&#xff1a; main.js 作为项目的入口文件&#xff0c;负责初始化 Vue 实例&#xff0c;并挂载到 DOM 上。 • 组件目录&#xff1a; components 目录包含项目的所有 Vue 组…...

BERT的中文问答系统32

我们需要在现有的代码基础上增加网络搜索功能&#xff0c;并在大模型无法提供满意答案时调用网络搜索。以下是完整的代码和文件结构说明&#xff0c;我们创建一个完整的项目结构&#xff0c;包括多个文件和目录。这个项目将包含以下部分&#xff1a; 主文件 (main.py)&#xf…...

linux之kylin系统nginx的安装

一、nginx的作用 1.可做高性能的web服务器 直接处理静态资源&#xff08;HTML/CSS/图片等&#xff09;&#xff0c;响应速度远超传统服务器类似apache支持高并发连接 2.反向代理服务器 隐藏后端服务器IP地址&#xff0c;提高安全性 3.负载均衡服务器 支持多种策略分发流量…...

【Oracle APEX开发小技巧12】

有如下需求&#xff1a; 有一个问题反馈页面&#xff0c;要实现在apex页面展示能直观看到反馈时间超过7天未处理的数据&#xff0c;方便管理员及时处理反馈。 我的方法&#xff1a;直接将逻辑写在SQL中&#xff0c;这样可以直接在页面展示 完整代码&#xff1a; SELECTSF.FE…...

基于uniapp+WebSocket实现聊天对话、消息监听、消息推送、聊天室等功能,多端兼容

基于 ​UniApp + WebSocket​实现多端兼容的实时通讯系统,涵盖WebSocket连接建立、消息收发机制、多端兼容性配置、消息实时监听等功能,适配​微信小程序、H5、Android、iOS等终端 目录 技术选型分析WebSocket协议优势UniApp跨平台特性WebSocket 基础实现连接管理消息收发连接…...

【机器视觉】单目测距——运动结构恢复

ps&#xff1a;图是随便找的&#xff0c;为了凑个封面 前言 在前面对光流法进行进一步改进&#xff0c;希望将2D光流推广至3D场景流时&#xff0c;发现2D转3D过程中存在尺度歧义问题&#xff0c;需要补全摄像头拍摄图像中缺失的深度信息&#xff0c;否则解空间不收敛&#xf…...

[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?

论文网址&#xff1a;pdf 英文是纯手打的&#xff01;论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误&#xff0c;若有发现欢迎评论指正&#xff01;文章偏向于笔记&#xff0c;谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...

Linux云原生安全:零信任架构与机密计算

Linux云原生安全&#xff1a;零信任架构与机密计算 构建坚不可摧的云原生防御体系 引言&#xff1a;云原生安全的范式革命 随着云原生技术的普及&#xff0c;安全边界正在从传统的网络边界向工作负载内部转移。Gartner预测&#xff0c;到2025年&#xff0c;零信任架构将成为超…...

Linux --进程控制

本文从以下五个方面来初步认识进程控制&#xff1a; 目录 进程创建 进程终止 进程等待 进程替换 模拟实现一个微型shell 进程创建 在Linux系统中我们可以在一个进程使用系统调用fork()来创建子进程&#xff0c;创建出来的进程就是子进程&#xff0c;原来的进程为父进程。…...

大语言模型(LLM)中的KV缓存压缩与动态稀疏注意力机制设计

随着大语言模型&#xff08;LLM&#xff09;参数规模的增长&#xff0c;推理阶段的内存占用和计算复杂度成为核心挑战。传统注意力机制的计算复杂度随序列长度呈二次方增长&#xff0c;而KV缓存的内存消耗可能高达数十GB&#xff08;例如Llama2-7B处理100K token时需50GB内存&a…...

html css js网页制作成品——HTML+CSS榴莲商城网页设计(4页)附源码

目录 一、&#x1f468;‍&#x1f393;网站题目 二、✍️网站描述 三、&#x1f4da;网站介绍 四、&#x1f310;网站效果 五、&#x1fa93; 代码实现 &#x1f9f1;HTML 六、&#x1f947; 如何让学习不再盲目 七、&#x1f381;更多干货 一、&#x1f468;‍&#x1f…...

C++使用 new 来创建动态数组

问题&#xff1a; 不能使用变量定义数组大小 原因&#xff1a; 这是因为数组在内存中是连续存储的&#xff0c;编译器需要在编译阶段就确定数组的大小&#xff0c;以便正确地分配内存空间。如果允许使用变量来定义数组的大小&#xff0c;那么编译器就无法在编译时确定数组的大…...