首页 文章 精选 留言 我的

精选列表

搜索[UI组件],共10000篇文章
优秀的个人博客,低调大师

Android优化——UI优化(二) 使用include标签复用布局

使用include标签复用布局 - 1.include标签的作用 假如说我下图的这个布局在很多界面都用到了,我该怎么办?每个页面都写一遍的话,代码太冗余,并且维护难度加大。 <LinearLayout 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" tools:context=".MainActivity" android:orientation="vertical"> <include layout="@layout/activity_clude_item"/> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:text="这是中间的东西"/> </LinearLayout> 上边的这个布局我就用的include标签,代码显然更加的整洁,并且增加的布局的复用性,降低了app的使用内存 - 2.include标签的用法 <include layout="@layout/activity_clude_item"/> 1 其中我们使用layout="@layout/activity_clude_item"设置复用的布局文件 本文转自 一点点征服 博客园博客,原文链接: http://www.cnblogs.com/ldq2016/p/5226576.html ,如需转载请自行联系原作者

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

Android UI开发第五篇——自定义列表

自定义列表,设置列表背景、列表的列背景、列表的间隔线。 借鉴了一些前辈的代码。 MainActivity.class public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //绑定Layout里面的ListView ListView list = (ListView) findViewById(R.id.ListView01); //生成动态数组,加入数据 ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>(); for(int i=0;i<5;i++) { if(i==0){ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.checked);//图像资源的ID map.put("ItemTitle", "个人信息"); map.put("LastImage", R.drawable.lastimage); listItem.add(map); }else if(i==1){ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.c);//图像资源的ID map.put("ItemTitle", "修改密码"); map.put("LastImage", R.drawable.lastimage); listItem.add(map); }else if(i==2){ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.d);//图像资源的ID map.put("ItemTitle", "网络设置"); map.put("LastImage", R.drawable.lastimage); listItem.add(map); }else if(i==3){ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.d);//图像资源的ID map.put("ItemTitle", "打印设置"); map.put("LastImage", R.drawable.lastimage); listItem.add(map); }else{ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.e);//图像资源的ID map.put("ItemTitle", "返回"); map.put("LastImage", R.drawable.lastimage); listItem.add(map); } } //生成适配器的Item和动态数组对应的元素 SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,// 数据源 R.layout.list_items,//ListItem的XML实现 //动态数组与ImageItem对应的子项 new String[] {"ItemImage","ItemTitle", "LastImage"}, //ImageItem的XML文件里面的一个ImageView,两个TextView ID new int[] {R.id.ItemImage,R.id.ItemTitle,R.id.last} ); //添加并且显示 list.setAdapter(listItemAdapter); //添加点击 list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { setTitle("点击第"+arg2+"个项目"); if(arg2 == 4){ MainActivity.this.finish(); } } }); //添加长按点击 list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { menu.setHeaderTitle("长按菜单-ContextMenu"); menu.add(0, 0, 0, "弹出长按菜单0"); menu.add(0, 1, 0, "弹出长按菜单1"); } }); } //长按菜单响应函数 @Override public boolean onContextItemSelected(MenuItem item) { setTitle("点击了长按菜单里面的第"+item.getItemId()+"个项目"); return super.onContextItemSelected(item); } } main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" xmlns:android="http://schemas.android.com/apk/res/android"> <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/ListView01" android:divider="@drawable/divider_color" android:dividerHeight="3dip" android:cacheColorHint="#00000000" /> </LinearLayout> list_item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:paddingBottom="4dip" android:paddingLeft="12dip" android:paddingRight="12dip" android:background="@drawable/list_bg"> <ImageView android:paddingTop="12dip" android:layout_alignParentLeft="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ItemImage" /> <TextView android:text="TextView01" android:layout_height="wrap_content" android:layout_marginTop="30px" android:textSize="20dip" android:paddingLeft="12dip" android:textColor="#000000" android:layout_width="fill_parent" android:id="@+id/ItemTitle" android:layout_toRightOf="@+id/ItemImage" /> <ImageView android:paddingTop="12dip" android:layout_marginTop="20px" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/last" /> </RelativeLayout> http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2888 http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2888 http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2888 http://www.devdiv.com/forum.php?mod=viewthread&tid=97913&page=1#pid591587 http://blog.csdn.net/zeng622peng/archive/2010/08/11/5804965.aspx http://www.devdiv.com/home.php?mod=space&uid=14682&do=blog&id=2888 本文转自xyz_lmn51CTO博客,原文链接:http://blog.51cto.com/xyzlmn/817375 ,如需转载请自行联系原作者

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

使用免费 .NET 组件快速将 PDF 转换为 PPT

在企业文档处理场景中,经常需要将 PDF 格式的资料转换为可编辑的演示文稿。在线转换工具存在文件上传的安全隐患,而依赖 Office 互操作的方案又需要在服务器安装完整的 Office 套件。本文分享一种基于 .NET 免费库的本地转换实现方式,全程离线处理,代码量少且易于集成。 --- ## 一、环境准备 ### 1.1 安装方式 本文采用 Free Spire.PDF for .NET 作为转换引擎。该库独立于 Adobe Acrobat 和 Microsoft Office,可直接在 .NET 应用中完成 PDF 到 PPTX 的格式转换。免费版本支持基础转换能力,适合小规模文档处理和个人项目使用。 **通过 NuGet 安装**(推荐): 在 Visual Studio 中打开项目,右键点击项目 → “管理 NuGet 程序包” → 浏览并搜索 `FreeSpire.PDF`,点击安装即可。 或在程序包管理器控制台中执行: ``` PM> Install-Package FreeSpire.PDF ``` ### 1.2 引入命名空间 ```csharp using Spire.Pdf; ``` --- ## 二、核心实现代码 将 PDF 转换为 PPT 的核心代码非常简洁,仅需几行: ```csharp using Spire.Pdf; namespace PDFtoPowerPoint { class Program { static void Main(string[] args) { // 创建 PdfDocument 实例 PdfDocument pdf = new PdfDocument(); // 加载 PDF 文档 pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\示例文档.pdf"); // 将 PDF 转换为 PPTX 文档 pdf.SaveToFile("PDF转PPT结果.pptx", FileFormat.PPTX); } } } ``` --- ## 三、代码详解 | 步骤 | 说明 | |------|------| | `PdfDocument pdf = new PdfDocument()` | 创建一个 PdfDocument 对象,用于表示待处理的 PDF 文档 | | `pdf.LoadFromFile("路径")` | 加载指定路径的 PDF 文件到内存中 | | `pdf.SaveToFile("输出.pptx", FileFormat.PPTX)` | 将文档保存为 PPTX 格式。PDF 的每一页都会转换为 PowerPoint 中的一张幻灯片 | | `pdf.Close()` | (建议)处理完成后关闭文档,释放资源 | ### 带异常处理的完整版本 ```csharp using System; using Spire.Pdf; namespace PDFtoPowerPoint { class Program { static void Main(string[] args) { string inputPath = @"C:\Users\Administrator\Desktop\示例文档.pdf"; string outputPath = "PDF转PPT结果.pptx"; try { PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile(inputPath); pdf.SaveToFile(outputPath, FileFormat.PPTX); pdf.Close(); Console.WriteLine("转换成功!"); } catch (Exception ex) { Console.WriteLine($"转换失败:{ex.Message}"); } } } } ``` --- ### 四、注意事项与限制 **⚠️ 1. 免费版的页数限制** Free Spire.PDF 作为社区版,存在以下限制: - 创建和加载 PDF 文档时,文档不超过 **10 页** - 将 PDF 转换为图片、Word、HTML、XPS 等格式时,仅支持转换前 **3 页** **2. 环境依赖** Free Spire.PDF for .NET 是一个独立的 .NET 库,**不需要在系统上安装 Adobe Acrobat 或 Microsoft Office** 即可运行。 **3. 转换质量** 转换后生成的 PPT 文档内容可以进一步编辑和修改。但对于包含复杂表格、图表或特殊字体的 PDF,建议实际测试转换效果。 --- ### 五、进阶场景 **1. 处理加密 PDF** 对于有密码保护的 PDF,可以在加载时提供密码: ```csharp pdf.LoadFromFile("加密文档.pdf", "password"); ``` **2. 批量转换** 遍历文件夹中的多个 PDF 文件,批量转换为 PPT: ```csharp string[] pdfFiles = Directory.GetFiles(@"C:\PDF文件夹\", "*.pdf"); foreach (string file in pdfFiles) { PdfDocument doc = new PdfDocument(); doc.LoadFromFile(file); string output = Path.ChangeExtension(file, ".pptx"); doc.SaveToFile(output, FileFormat.PPTX); doc.Close(); } ``` --- ### 六、总结 这种本地转换方案的优势在于部署简单、数据安全、无需额外软件授权。对于内部系统集成、批量文档预处理等场景,几行代码即可完成核心能力接入。 需要注意的是,PDF 到 PPT 的转换本质上是格式逆向还原,不存在 100% 完美还原的方案。对于排版要求严格的正式演示文稿,建议转换后进行人工校对和版式调整

资源下载

更多资源
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应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

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

用户登录
用户注册
修改密码
忘记密码