实现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]; ...
随机推荐
- 转!!Java 基础面试题的剖析: short s1=1;s1 = s1 +1 报错? s1+=1 呢
short s1=1;s1 = s1 +1会报错吗? package common; public class ShortTypeTest { /* * @param args */ publi ...
- hiho_1070_RMQ
题目 区间最小值查询,但是支持对数组中的任意数字进行修改. 分析 采用RMQ_ST算法的O(1)算法不支持修改,因为每次修改都要重新设置动归数组.因此采用线段树解决,修改和查询的复杂度均为O(logN ...
- PHP 实现多服务器共享 SESSION 数据
PHP 实现多服务器共享 SESSION 数据 2011 年 12 月 05 日评论暂缺 一.问题起源 稍大一些的网站,通常都会有好几个服务器,每个服务器运行着不同功能的模块,使用不同的二级域名,而一 ...
- 使用ICMP协议Ping网络主机
#coding:utf-8 #!/usr/bin/env python import os import argparse import socket import struct import sel ...
- javascript的语句和函数
1.for-in语句:是一种精准的迭代语句,可以用来枚举对象的属性. 2.label语句:在代码中添加标签,以便将来使用,由break和continue语句调用. 3.with语句:将代码的作用域设置 ...
- centos7 修改selinux 开机导致 faild to load SELinux policy freezing 错误
centos7 修改selinux 开机导致 faild to load SELinux policy freezing 错误 之前把selinux关闭了,这次想打开selinux,于是修改了 /e ...
- 清理PC垃圾
@echo off pause echo 正在清除系统垃圾文件,请稍等...... del /f /s /q %systemdrive%\*.tmp del /f /s /q %systemdrive ...
- 【CITE】C# 如何 实现一个窗体和另一个窗体始终保持相对的位置
C# 如何 实现一个窗体和另一个窗体始终保持相对的位置,任由一个窗体移动,当点击按钮时,弹出的另一个窗体也与之保持相对位置(如左上角)你根据第一个窗体的location去算第二个窗体的location ...
- 4.2 EF的CRUD控制器代码
以下的例子以留言本作为依据. 1.添加 public ActionResult Create() { return View(); } // // POST: /Contact/Create [Htt ...
- HTML5 game engines
The following are few examples of game engines implemented with HTML5 and JavaScript: Construct 2: O ...