| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
awuzefeng
6年前发布

Android开源:SmartTable-Android 自动生成表格框架

   <h2>SmartTable</h2>    <p>一款android自动生成表格框架</p>    <ul>     <li><a href="/misc/goto?guid=4959756469200420725" rel="nofollow,noindex">English README</a></li>     <li><a href="/misc/goto?guid=4959756469296251636" rel="nofollow,noindex">apk version 1.5版本下载地址</a></li>     <li><a href="/misc/goto?guid=4959756469374716991" rel="nofollow,noindex">历史版本介绍</a></li>     <li><a href="/misc/goto?guid=4959756469470071956" rel="nofollow,noindex">更多功能详情介绍</a></li>    </ul>    <p>功能介绍</p>    <ol>     <li>快速配置自动生成表格;</li>     <li>自动计算表格宽高;</li>     <li>表格列标题组合;</li>     <li>表格固定左序列、顶部序列、第一行、列标题、统计行;</li>     <li>自动统计,排序(自定义统计规则);</li>     <li>表格图文、序列号、列标题格式化;</li>     <li>表格各组成背景、文字、网格、padding等配置;</li>     <li>表格批注;</li>     <li>表格内容、列标题点击事件;</li>     <li>缩放模式和滚动模式;</li>     <li>注解模式;</li>     <li>内容多行显示;</li>     <li>分页模式;</li>     <li>首尾动态添加数据;</li>     <li>丰富的格式化;</li>     <li>支持二维数组展示(用于类似日程表,电影选票等)待完善 <img src="https://simg.open-open.com/show/67039439fc1d7016cecfac42b207ce7d.jpg"></li>    </ol>    <p><img src="https://simg.open-open.com/show/fe1cec767c0f5ca0e5926dbc097bd56b.jpg"></p>    <p>视频展示 <img src="https://simg.open-open.com/show/775b20443263a2d4db60c1d274703ba9.png"></p>    <p><img src="https://simg.open-open.com/show/0805aefd9290606558100d48909ae254.gif"></p>    <p><img src="https://simg.open-open.com/show/2f174565f7267b040a23090243b45186.gif"></p>    <p>如何使用</p>    <ul>     <li>引用</li>    </ul>    <ul>     <li>Step 1. 添加 JitPack repository 到你的build文件</li>    </ul>    <pre>  <code class="language-java">allprojects {    repositories {     ...     maven { url 'https://www.jitpack.io' }    }   }</code></pre>    <ul>     <li>Step 2. 增加依赖</li>    </ul>    <pre>  <code class="language-java">dependencies {           compile 'com.github.huangyanbin:SmartTable:1.5'   }</code></pre>    <ul>     <li>使用表格View</li>    </ul>    <pre>  <code class="language-java"><com.bin.david.form.core.SmartTable         android:id="@+id/table"         android:layout_width="match_parent"         android:layout_height="match_parent"        /></code></pre>    <p>- 注解模式</p>    <ul>     <li>在您需要生成的表格的类增加注解</li>    </ul>    <pre>  <code class="language-java">@SmartTable(name="表名")</code></pre>    <ul>     <li>在你需要显示的字段增加注解</li>    </ul>    <pre>  <code class="language-java">// id为该字段所在表格排序位置   @SmartColumn(id =1,name = "列名")   //如果需要查询到该成员变量里面去,通过设置type实现   @SmartColumn(type = ColumnType.Child)</code></pre>    <ul>     <li>设置表格数据</li>    </ul>    <pre>  <code class="language-java">table = findViewById(R.id.table);          table.setData(list);</code></pre>    <p>注解模式就是这么简单,你可以直接运行查看效果了。当然这只是注解基本配置,注解里面还有自动统计,列组合等,如果你想要了解注解更多,请查看demo.</p>    <p>- 基本模式</p>    <pre>  <code class="language-java">//普通列     Column<String> column1 = new Column<>("姓名", "name");     Column<Integer> column2 = new Column<>("年龄", "age");     Column<Long> column3 = new Column<>("更新时间", "time");      Column<String> column4 = new Column<>("头像", "portrait");      //如果是多层,可以通过.来实现多级查询        Column<String> column5 = new Column<>("班级", "class.className");     //组合列    Column totalColumn1 = new Column("组合列名",column1,column2);      //表格数据 datas是需要填充的数据     final TableData<User> tableData = new TableData<>("表格名",userList,totalColumn1,column3);     //设置数据      table = findViewById(R.id.table);      //table.setZoom(true,3);是否缩放      table.setTableData(tableData);</code></pre>    <p>- 基本方法介绍</p>    <p>Column 构造方法中还有两个参数 IFormat<T> , IDrawFormat<T> 。其中 IFormat<T> 是用于格式化显示文字,比如 User 对象中有更新时间字段 time 时间戳。我们想要显示不同格式,就可以重写该方法。 IDrawFormat<T> 是用于显示绘制格式化,比如 User 对象中有头像字段 portrait 时间戳,就可以使用该方法,框架提供几种 IDrawFormat 包括(文字、Bitmap、Resoure图片、图文结合)。</p>    <p>Column 提供了</p>    <ol>     <li>是否自动排序 setAutoCount(boolean isAutoCount)</li>     <li>是否反序排列 isReverseSort</li>     <li>设置排序比较 setComparator</li>     <li>统计格式化 setCountFormat</li>     <li>点击事件 OnColumnItemClickListener</li>    </ol>    <p>TableData 中基本方法</p>    <ol>     <li>设置排序列 setSortColumn</li>     <li>设置列标题格式化 settitleDrawFormat</li>     <li>设置顶部序列号格式化 setXSequenceFormat</li>     <li>设置左边序列号格式化 setYSequenceFormat</li>     <li>设置是否显示统计 setShowCount</li>    </ol>    <p>TableConfig 中基本方法</p>    <ol>     <li>设置内容文字样式 setContentStyle</li>     <li>设置左边序列文字样式 setYSequenceStyle</li>     <li>设置顶部序列文字样式 setXSequenceStyle</li>     <li>设置列标题文字样式 setColumnTitleStyle</li>     <li>设置表格标题文字样式 setTableTitleStyle</li>     <li>设置统计行样式 setCountStyle</li>     <li>设置列标题网格样式 setColumnTitleGridStyle</li>     <li>设置表格网格样式 setGridStyle</li>     <li>设置网格列padding setVerticalPadding</li>     <li>设置网格行padding setHorizontalPadding</li>     <li>设置左序列背景 setYSequenceBackgroundColor</li>     <li>设置右序列背景 setXSequenceBackgroundColor</li>     <li>设置列标题背景 setColumnTitleBackgroundColor</li>     <li>设置内容背景 setContentBackgroundColor</li>     <li>设置统计行背景 setCountBackgroundColor</li>     <li>固定左侧 setFixedYSequence</li>     <li>固定顶部 setFixedXSequence</li>     <li>固定列标题 setFixedTitle</li>     <li>固定第一列 setFixedFirstColumn //1.4版本取消了</li>     <li>固定统计行 setFixedCountRow</li>    </ol>    <h3>总结</h3>    <p>写完SmartChart之后,对android 绘图有了进一步的理解。开始了做SmartTable,开始只是一个小demo,经过一星期的上班偷着写,基本完成表格主要功能,本来还有合并等功能,由于后面没有采用,便只做了开始设计功能,已经满足日常需求。</p>    <p>android中使用表格的场景很少,主要屏幕一页放不下,用户体验不好。在实现过程中,尽量做到体验感好些,我感觉通过固定标题和第一行体验最好,所以默认设置固定。当然你可以自己设置。里面还有不少的坑,希望有需要的朋友可以使用它。</p>    <h2><em>License</em></h2>    <p>SmartTable is released under the Apache 2.0 license.</p>    <pre>  <code class="language-java">Copyright 2017 Huangyanbin.    Licensed under the Apache License, Version 2.0 (the "License");  you may not use this file except in compliance with the License.  You may obtain a copy of the License at following link.         http://www.apache.org/licenses/LICENSE-2.0    Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitat</code></pre>    <p> </p>    <p> </p>    <p> </p>    
 本文由用户 awuzefeng 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1516159612500.html
Android 安卓 Android开发 移动开发