实现IOS圆角风格的列表ListView
这段代码目前已经加在我的一个jar包androidkit中,还没发布。
适用于android1.6以上,不依赖其他jar包
使用时不需要继承这里的RoundListAdapter。只需要在你实现了ListAdapter的类中,传入一个RoundParams的对象,并在getView方法返回前调用这里RoundListAdapter类提供的静态方法。
RoundListAdapter.setItemBackground(position, switcherView, mParams,
getCount());
1. [代码]
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* * @(#)RoundListAdapter.java Project:com.sinaapp.msdxblog.androidkit * Date:2012-12-6 * * Copyright (c) 2011 CFuture09, Institute of Software, * Guangdong Ocean University, Zhanjiang, GuangDong, China. * All rights reserved. * * 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 * * 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 * limitations under the License. */package com.lurencun.cfuture09.androidkit.widget.roundlist;import android.view.View;import android.widget.ListAdapter;/** * @author Geek_Soledad (66704238@51uc.com) */public abstract class RoundListAdapter implements ListAdapter { /** * 圆角ListView的参数类。定义了顶部背景,底部背景,中间背景及单独一个时的背景。 * * @author msdx * */ public static class RoundParams { public int topResid; public int middleResid; public int bottomResid; public int lonelyResid; public RoundParams(int topResid, int middleReside, int bottomResid, int lonelyResid) { this.topResid = topResid; this.middleResid = middleReside; this.bottomResid = bottomResid; this.lonelyResid = lonelyResid; } } public static void setItemBackground(int position, View item, final RoundParams mParams, final int count) { if (count == 1) { item.setBackgroundResource(mParams.lonelyResid); } else if (position > 0 && position < count - 1) { item.setBackgroundResource(mParams.middleResid); } else if (position == 0) { item.setBackgroundResource(mParams.topResid); } else { item.setBackgroundResource(mParams.bottomResid); } }} |
2. [代码]使用示例 悦德财富“https://www.yuedecaifu.com”
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* * @(#)LocalAdapter.java Project:RTKSETTINGS * Date:2013-1-9 * * Copyright (c) 2013 Geek_Soledad. * All rights reserved. * * 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 * * 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 * limitations under the License. */package com.realtek.msdx.rtksettings.view;import java.util.ArrayList;import java.util.List;import android.app.TvManager;import android.content.Context;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import com.lurencun.cfuture09.androidkit.widget.roundlist.RoundListAdapter;import com.lurencun.cfuture09.androidkit.widget.roundlist.RoundListAdapter.RoundParams;import com.realtek.msdx.rtksettings.activity.MainActivity;import com.realtek.msdx.rtksettings.bean.LocalSettingsBean;/** * @author Geek_Soledad (msdx.android@tom.com) */public class LocalAdapter extends BaseAdapter { private RoundParams mParams; private Context mContext; public LocalAdapter(Context context, RoundParams params) { super(); mContext = context; mParams = params; } @Override public int getCount() { return 5; } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // 在这里创建view, //SwitcherTextView view = new SwitcherTextView(mContext); // 然后在返回view前进行调用 RoundListAdapter.setItemBackground(position, view, mParams, getCount()); return view; }} |
实现IOS圆角风格的列表ListView的更多相关文章
- android开发(3):列表listview的实现 | 下拉刷新
APP里面的列表太常用了,系统提供的listview或grideview可以做到.另外,我希望这个列表能够下拉时触发刷新,于是考虑使用封装了这个功能的开源项目,这里介绍这个: https://gith ...
- iOS圆角view的Swift实现(利用Core Graphics绘制)
iOS圆角view的Swift实现(利用Core Graphics绘制) 因为app的列表用用到了圆形图片的头像,所以去探究并思考了一下这个问题.首先这个问题有两个方向的解决方案: 把图片弄成圆形的. ...
- 离屏渲染学习笔记 /iOS圆角性能问题
离屏渲染学习笔记 一.概念理解 OpenGL中,GPU屏幕渲染有以下两种方式: On-Screen Rendering 意为当前屏幕渲染,指的是GPU的渲染操作是在当前用于显示的屏幕缓冲区中进行. O ...
- 【IOS】模仿windowsphone列表索引控件YFMetroListBox
有没有觉得UITableView自带的右侧索引很难用,我一直觉得WindowsPhone中的列表索引非常好用. 所以呢,我们来实现类似Windows Phone中的列表索引(这就是信仰). 最终实现效 ...
- iOS团队风格的统一
不知不觉团队已经有了4个iOS开发,大家的代码风格完全不一样,所以每次改起别人的代码就头疼,理解起来不是那么顺畅,如鲠在喉.所以,就开了场分享会,把一些基本调用方法和代码风格统一了一下. 前言 主要参 ...
- 苹果微信下载 iOS微信各版本列表
微信在不断地更新迭代,ios微信下载点击这里立即开始(手机电脑都可以,电脑端要安装iTunes),每个版本都放出一些新的功能或修复相关错误,详情可以点击下面的版本链接进行查看.(这里有Android微 ...
- Android iOS Dribbble风格边栏菜单实现
随着IOS7的推出,大量移动应用也开始进行了重新设计.,开始应用大量的扁平化.可以说现在IOS和Android的风格设计方面确实是在逐渐地靠拢. ReisdeMenu 创意灵感来自于Dribbble( ...
- iOS 圆角那些事(转)
似乎没有那家公司比Apple更爱圆角了,事实上,圆角也会让图形/产品看起来更加无侵略性,能够带来更好的用户体验.iOS开发中各种圆角也随处可见,最简单给控件添加圆角的方式就是给视图的layer设置co ...
- IOS之【属性列表】
@implementation JamesWongViewController - (void)viewDidLoad { [superviewDidLoad]; [selfwritePerson]; ...
随机推荐
- 转!!各种数据库的jdbc驱动下载及连接方式
各种数据库驱动 数据库名称 下载地址 说明 Mysql http://www.mysql.com/products/connector/j/ Shipped. But need to download ...
- iOS 细碎知识整理
1centerX,即x轴的中点 centery,即y轴的中点
- hiho_1048_状态压缩2
题目大意 用1x2的单元拼接出 NxM的矩形,单元可以横放或者纵放,N < 1000, M <= 5. 求不同的拼接方案总数. 分析 计算机解决问题的基本思路:搜索状态空间.如果采用dfs ...
- 向java全台推送数据等
(1)http://www.cnblogs.com/xdp-gacl/p/3789624.html (2)VenusWebHelper 等等 public void test(){ String f ...
- 【转】 Linux进程间通信
一.进程间通信概述进程通信有如下一些目的:A.数据传输:一个进程需要将它的数据发送给另一个进程,发送的数据量在一个字节到几M字节之间B.共享数据:多个进程想要操作共享数据,一个进程对共享数据的修改,别 ...
- sqlserver计算表使用大小sql
) create table #spt_space ( ) null, [rows] int null, ) null, ) null, ) null, ) null ) set nocount on ...
- Qt之QThread(深入理解)
简述 为了让程序尽快响应用户操作,在开发应用程序时经常会使用到线程.对于耗时操作如果不使用线程,UI界面将会长时间处于停滞状态,这种情况是用户非常不愿意看到的,我们可以用线程来解决这个问题. 前面,已 ...
- hiphop-php 搭建 (CentOS)
前提:只支持64位系统 升级GCC: https://github.com/jackywei/HOW-TO-BUILD-HHVM-WiKi/wiki/Build-&-Install-GCC4. ...
- Java网络通信
一.基本概念 1.网络程序: 能够接受另一台计算机发送过来的数据或者能够向另一台计算机发送数据的程序叫做网络程序. 2.IP 能够在网络中唯一标示一台主机的编号就是IP 3.端口号 16位数字表示 4 ...
- Chrome开发,debug的使用方法。(转)
怎样打开Chrome的开发者工具? 你可以直接在页面上点击右键,然后选择审查元素: 或者在Chrome的工具中找到: 或者,你直接记住这个快捷方式: Ctrl+Shift+I (或者Ctrl+Shif ...