实现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]; ...
随机推荐
- 转!!数据库 第一范式(1NF) 第二范式(2NF) 第三范式(3NF)的 联系和区别
范式:英文名称是 Normal Form,它是英国人 E.F.Codd(关系数据库的老祖宗)在上个世纪70年代提出关系数据库模型后总结出来的,范式是关系数据库理论的基础,也是我们在设计数据库结构过程中 ...
- java 反射机制的实例
[案例1]通过一个对象获得完整的包名和类名 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 package Reflect; /** * 通过一个对象获得完整的包名和类名 ...
- Docker 使用指南 (二)—— 搭建本地仓库
版权声明:本文由田飞雨原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/94 来源:腾云阁 https://www.qclou ...
- 20145218 《Java程序设计》第01次实验报告
北京电子科技学院(BESTI)实验报告 课程:Java程序设计 班级:1452 指导教师:娄嘉鹏 实验日期:2016.04.08 实验名称:Java开发环境的熟悉(Linux + Eclipse) 实 ...
- robot.libdocpkg package
mplements the Libdoc tool. The command line entry point and programmatic interface for Libdoc are pr ...
- python 练习 6
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import deque from math import log10 def p ...
- call(京基填小票拍照片)
同事的写的函数结构,先是几个函数表达式var a = function(){},里面再是函数声明function a(){} 里面用了好多call,网上搜了一下call的用途: 1. http://w ...
- datagridview 中添加了一个button类型的列,怎么写button的事件
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- input覆盖select实现select可写可选择
1.有时需要一个select选择框,但是对select选择框希望是既可以选择也可以进行输入.下边的代码就是在select选择框上放了一个input框,覆盖在select上面.实现伪装的select效果 ...
- oracle错误码
ORA-00001: 违反唯一约束条件 (.) ORA-00017: 请求会话以设置跟踪事件 ORA-00018: 超出最大会话数 ORA-00019: 超出最大会话许可数 ORA-00020: 超出 ...