实现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]; ...
随机推荐
- 20160815_Redis安装
OS: CentOS6.4(x64) 参考网址: http://www.cnblogs.com/haoxinyue/p/3620648.html http://www.codeceo.com/arti ...
- jQuery内置函数 ready
jQuery给我们提供了一些非常实用的函数 ready:加载函数 传统事件只能绑定一个函数 后面的函数会把前面的函数覆盖 js中用的是 window.onload = function(){}; j ...
- gdb 调试学习
gdb 是unix/linux 系统下的程序调试工具,和IDE(如VS, Eclipse等)的图形化调试工具相比,gdb在断点,跟踪显示方面有着不足,但是它在某些方面比图形化调试工具更加丰富的功能. ...
- Mysql 联结表
- kafka - topic
http://www.cnblogs.com/yurunmiao/p/5550906.html http://www.cnblogs.com/chushiyaoyue/p/5695826.html
- img src 使用 base64 图片数据
img src 使用 base64 图片数据 在网页上显示一张图片通常是 <img src="xxx.png" > 或 <img src="www.ur ...
- js更改input标签的读写属性
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- django 2
创建一个管理员用户 首先,我们需要创建一个用户可以登录到管理网站. 运行 下面的命令: $ python manage.py createsuperuser 输入你想要的用户名,按回车. Userna ...
- python 练习 5
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import deque def z69(): '''猜牌术(1) 魔术师,最上面 ...
- 30 个有用的 HTML5 和 CSS3 表单设计
基本上表单是任何一个网站都必须要用到的元素,本文介绍的这 30 个设计方案供你参考,这些方案如果要单独下载完整可运行的文件则需要支付2-5美元的费用. 1. Fresh Forms 2. Pretty ...