发布时间:2026/7/28 16:26:05
卜若的代码笔记-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/7/28 16:26:05

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

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

2026/7/28 16:26:05

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

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

2026/7/28 17:31:11

的文档格式较为复杂,难以完美支持所有格式特性,且图片资源的处理存在技术难点。 现在,有一个插件可以很好地支持导入 Markdown ...

告别格式噩梦:用这款插件轻松导入Markdown文档,图片处理不再是难题 作为一名技术博主,我经常需要处理各种文档格式的转换问题。相信很多同行都有类似的经历:当你辛辛苦苦用Markdown写好了技术文章,想要导入到某个平台或…

2026/7/28 17:31:11

Spring Boot+Vue健康管理平台设计与实现

1. 项目背景与核心价值这个个人健康管理平台的设计与实现,本质上是在解决现代人普遍面临的健康数据碎片化问题。我见过太多人手机里装着五六个健康类App——运动用一个、饮食记录用一个、睡眠监测又用另一个,数据完全割裂。这个毕设项目的巧妙之处在于&a…

2026/7/28 17:31:11

小白程序员必看:AI Agent 招聘热潮与高薪秘诀大揭秘

2026年,AI Agent岗位招聘量暴涨300%,薪资领跑技术类岗位。本文梳理了AI Agent的招聘市场全貌,解析了其概念、原理、落地价值与现存挑战。AI Agent是具备自主目标、思考、执行能力的智能主体,区别于被动应答式AI。企业争抢AI Agent…

2026/7/28 17:31:11

手机端弹窗页面

手机端页面&#xff0c;下图效果如何实现&#xff1f; HTML代码&#xff1a; jQuery WeUI <meta name"description" content"Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your docum…

2026/7/28 17:26:10

a label can only be part of a statement and a declaration is not a statement

原因是由于在case之后进行变量的声明对此问题的分析&#xff1a;由于switch的几个case语句在同一个作用域&#xff08;因为case 语句只是标签&#xff0c;它们共属于一个swtich语句块&#xff09;&#xff0c;所以如果在某个case下面声明变量的话&#xff0c;对象的作用域是在俩…

2026/7/28 13:41:25

PDF合并与动态水印的工程化方案:2026国内免费工具实测对比

一、背景与测试方案 在实际项目交付中&#xff0c;PDF文件合并与版权保护水印的叠加是一个高频但容易被低估的技术需求。典型的处理链路涉及&#xff1a;多源PDF的文件流合并、页面级水印渲染&#xff08;含透明度混合与图层叠加&#xff09;、输出文件体积控制。看似简单的操作…

2026/7/28 0:03:34

学术论文研究创新点梳理与核心价值提炼指南

本科毕业论文是大学四年最大的坎。开题报告憋一周写不出三页&#xff0c;找文献翻遍十几个网站还是缺关键资料&#xff0c;写正文卡壳半天憋不出一句话&#xff0c;降重改到凌晨三点结果逻辑全乱&#xff0c;答辩前一天PPT还没做完。别慌&#xff0c;亲测这四个工具能让你少熬半…

2026/7/28 0:03:34

开发商售楼处数字化升级怎么做?

房企的数字化转型投入正在快速增长&#xff0c;据行业数据显示&#xff0c;2025年房企数字化投入规模已突破800亿元&#xff0c;年复合增长率达35%。售楼处的数字化升级不是单一环节的改造&#xff0c;而是从“获客-展示-成交-服务”全链路的系统升级。数字化升级四步法第一步&…

2026/7/28 0:03:34

模型不再值钱之后,AI 编程工具在争什么

2026 年 7 月&#xff0c;AI 编程工具赛道发生了一个标志性转折&#xff1a;模型本身不再值钱了。当 Kimi K3 开源模型在编程基准上击败 GPT 和 Claude&#xff0c;当 GitHub Copilot 第一次把开源模型纳入选择器&#xff0c;当 OpenAI 把 Codex 并入 ChatGPT 做成三合一超级应…

2026/7/28 4:38:09

3个高效策略:快速掌握Axure中文界面配置

3个高效策略&#xff1a;快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…