卜若的代码笔记-android系列-插件:带图片的Spinner插件

发布时间:2026/9/15 7:01:24

卜若的代码笔记-android系列-插件:带图片的Spinner插件 1.该插件是我自己封装了一下提高用户体验具体解释请转以下https://blog.csdn.net/Zaajuan1150/article/details/817048652.插件封装package com.draw.depp.deeplearningdrawer.Plugins.ImageSpinnerPlugins; import android.content.Context; import android.view.View; import android.widget.AdapterView; import android.widget.SimpleAdapter; import android.widget.Spinner; import com.draw.depp.deeplearningdrawer.R; import com.draw.depp.deeplearningdrawer.Tool.CarColorUtil; import com.draw.depp.deeplearningdrawer.Tool.Debug; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ImageAdapter extends SimpleAdapter { public Context ct; public ImageAdapter(Context context, List? extends MapString, ? data, int resource, String[] from, int[] to) { super(context, data, resource, from, to); ct context; } public static ImageAdapter createImageAdapter(Context ctt,ListMapString, Object dataMap){ ImageAdapter adp new ImageAdapter(ctt, dataMap, R.layout.spinner_2_example, new String[] { image, text }, new int[] {R.id.colorview, R.id.textview }); return adp; } public static ListMapString,Object mapList new ArrayList(); public static ImageAdapter createImageAdapter(Context ct2){ ListMapString,Object l2 new ArrayList(); for (Map k: mapList ) { l2.add(k); } mapList.clear(); ImageAdapter i2 createImageAdapter(ct2,l2); return i2; } public static void addSpinner(String textValue,Object obj){ MapString,Object m2 new HashMapString,Object(); m2.put(text,textValue); m2.put(image,obj); mapList.add(m2); } }3.使用到的资源R.layout.spinner_2_example?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/android android:layout_widthmatch_parent android:layout_heightwrap_content android:orientationhorizontal android:gravitycenter ImageView android:idid/colorview android:layout_width20dp android:layout_height20dp android:layout_marginLeft10dp android:srcmipmap/ic_launcher / TextView android:idid/textview android:layout_widthmatch_parent android:layout_height40dp android:gravitycenter|left android:paddingLeft10dp android:textSize15dp / /LinearLayout4.调用Spinner spinner findViewById(R.id.type); ImageAdapter.addSpinner(广州,R.mipmap.ic_launcher); ImageAdapter.addSpinner(贵阳,R.mipmap.ic_launcher); ImageAdapter.addSpinner(华西,R.mipmap.ic_launcher); ImageAdapter adp ImageAdapter.createImageAdapter(MainActivity.this); spinner.setAdapter(adp);5.预览6.关于怎么抽出text的值一个自写解析器package com.draw.depp.deeplearningdrawer.Plugins.ImageSpinnerPlugins; public class ImageAdapterAnalyser { public String analyserValue ; public String[] analyserList ; public String text; public String image; public ImageAdapterAnalyser(String key){ this.analyserValue key; char[] charArray new char[key.length() - 2]; int index 0; for (char a : analyserValue.toCharArray()){ if (a {){ continue; } if(a }){ continue; } charArray[index] a; index; } analyserValue new String(charArray); analyserList analyserValue.split(,); image analyserList[0].split()[1].trim(); text analyserList[1].split()[1].trim(); } }7.解析调用spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { Override public void onItemSelected(AdapterView? parent, View view, int position, long id) { String content parent.getItemAtPosition(position).toString(); Debug.Log(new ImageAdapterAnalyser(content).text); type content; }
延伸阅读

更多相关文章

2026/9/15 7:00:50

Go入门:main包与main函数的特殊地位

Go入门:main包与main函数的特殊地位大家好,我是你们的Go语言向导。上一篇我们全面解析了Go源文件的基本结构。今天我们把焦点放在Go程序中最特殊也是最重要的组合——main包与main函数。每一个可运行的Go程序都离不开它们,但你真的完全理解它…

2026/9/13 22:33:39

APP运营如何才能增强用户粘性

app软件拉新后,通常会出现很多的客户外流。怎么会外流?可能是找不着都要的內容,或感受关键功用心里不舒服。也有可是所有人的时长泛娱乐化,客户的潜心速度快,如果免费下载时长慢,客户坚持不懈几秒钟可能被会舍弃了。要提高客户的…

2026/9/15 6:56:38

AI编程助手协同配置:Claude+Router+DeepSeek实战

1. 项目背景与核心价值去年在搭建智能开发环境时,我尝试将多个AI编程助手整合到工作流中。经过三个月的迭代测试,最终形成了这套基于Claude Code、Router和DeepSeek的协同配置方案。这种组合最大的优势在于:Claude Code擅长代码补全和语法检查…

2026/9/15 6:56:38

BEVFormer:端到端空间建模的自动驾驶感知范式

1. 为什么BEVFormer不是“又一个Transformer变体”,而是自动驾驶感知范式的分水岭BEVFormer这个词最近在自动驾驶算法圈里几乎成了高频词,但很多人一看到“Former”就下意识归类为“Transformer的又一个分支”,甚至直接跳到代码复现环节——结…

2026/9/15 6:56:38

AI API生产化集成:从选型到可管理的完整指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/15 6:56:38

金融数据架构革新:从顶层规划到底层落地的系统指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/15 4:54:30

拯救者Y7000黑屏故障排查与维修实战指南

1. 项目概述:一台黑屏的拯救者Y7000,到底卡在哪一步? 联想拯救者Y7000系列笔记本,从2018年第一代搭载i5-8300H开始,到后来的i7-9750H、i7-10750H、i5-11400H,再到2023年款的R7-7840HS,它始终是学…

2026/9/15 0:01:16

AI英语单词APP开发:自适应学习算法与移动端优化实践

1. 项目概述 作为一名在移动应用开发领域摸爬滚打多年的老手,我最近完成了一个AI英语单词APP的开发项目。这个项目将传统单词记忆方法与现代AI技术相结合,打造了一款能够智能适应不同用户学习习惯的英语学习工具。 市面上大多数单词APP都存在一个通病&a…

2026/9/15 0:01:16

Flutter与OpenHarmony结合开发手语学习APP实战

1. 项目背景与核心价值作为一名同时接触过Flutter和OpenHarmony的开发者,最近我完成了一个基于Flutter for OpenHarmony的手语学习APP实战项目。这个项目最大的特点在于实现了跨平台框架与国产操作系统深度结合的创新实践——用Flutter开发的应用能完美运行在OpenHa…

2026/9/15 0:01:16

六个月成为机器人工程师:从ROS2到SLAM的实战路径

1. 六个月的紧迫感从哪来:先搞清楚你要成为哪种机器人工程师说实话,六个月的期限并不是一个宽松的时间线。市面上任何一本正经的机器人学教材都超过五百页,ROS2的官方文档可以翻到你怀疑人生,再加上ABB、KUKA这些工业机器人厂家动…

2026/9/14 11:59:31

USB Type-C PCB布局分区设计:电源、高速信号与PD协议全攻略

做硬件这行,Type-C接口算是典型的“看着简单,做起来全坑”的东西。光引脚就24个,高低速信号、电源、控制线全部塞在一个小小的连接器里,如果PCB布局不做规划,打样回来基本就是“插上没反应”、“高速掉线”、“静电一打…

2026/9/14 13:53:59

系统编程学习原型如何补齐稳定性边界

系统编程学习原型如何补齐稳定性边界预算有限时&#xff0c;我先优化明显多余的复制&#xff0c;而不是猜测性地换容器。用借用传递只读数据通常就能减少分配&#xff1a; fn parse(line: &str) -> Result<Item, Error> { /* ... */ }用基准确认热点确实在分配&am…

2026/9/14 11:22:57

雨花区哪家财务公司代理记账比较好?

在雨花区&#xff0c;企业处理财税事务常常面临诸多挑战&#xff0c;选择一家靠谱的财务公司至关重要。湖南巨勤财务管理咨询有限公司就是本地正规实体财税服务机构&#xff0c;深耕本地工商财税行业多年&#xff0c;熟悉当地工商局、税务局最新政策与申报流程。主营公司注册、…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
咨询二维码