这段代码目前已经加在我的一个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的更多相关文章

  1. android开发(3):列表listview的实现 | 下拉刷新

    APP里面的列表太常用了,系统提供的listview或grideview可以做到.另外,我希望这个列表能够下拉时触发刷新,于是考虑使用封装了这个功能的开源项目,这里介绍这个: https://gith ...

  2. iOS圆角view的Swift实现(利用Core Graphics绘制)

    iOS圆角view的Swift实现(利用Core Graphics绘制) 因为app的列表用用到了圆形图片的头像,所以去探究并思考了一下这个问题.首先这个问题有两个方向的解决方案: 把图片弄成圆形的. ...

  3. 离屏渲染学习笔记 /iOS圆角性能问题

    离屏渲染学习笔记 一.概念理解 OpenGL中,GPU屏幕渲染有以下两种方式: On-Screen Rendering 意为当前屏幕渲染,指的是GPU的渲染操作是在当前用于显示的屏幕缓冲区中进行. O ...

  4. 【IOS】模仿windowsphone列表索引控件YFMetroListBox

    有没有觉得UITableView自带的右侧索引很难用,我一直觉得WindowsPhone中的列表索引非常好用. 所以呢,我们来实现类似Windows Phone中的列表索引(这就是信仰). 最终实现效 ...

  5. iOS团队风格的统一

    不知不觉团队已经有了4个iOS开发,大家的代码风格完全不一样,所以每次改起别人的代码就头疼,理解起来不是那么顺畅,如鲠在喉.所以,就开了场分享会,把一些基本调用方法和代码风格统一了一下. 前言 主要参 ...

  6. 苹果微信下载 iOS微信各版本列表

    微信在不断地更新迭代,ios微信下载点击这里立即开始(手机电脑都可以,电脑端要安装iTunes),每个版本都放出一些新的功能或修复相关错误,详情可以点击下面的版本链接进行查看.(这里有Android微 ...

  7. Android iOS Dribbble风格边栏菜单实现

    随着IOS7的推出,大量移动应用也开始进行了重新设计.,开始应用大量的扁平化.可以说现在IOS和Android的风格设计方面确实是在逐渐地靠拢. ReisdeMenu 创意灵感来自于Dribbble( ...

  8. iOS 圆角那些事(转)

    似乎没有那家公司比Apple更爱圆角了,事实上,圆角也会让图形/产品看起来更加无侵略性,能够带来更好的用户体验.iOS开发中各种圆角也随处可见,最简单给控件添加圆角的方式就是给视图的layer设置co ...

  9. IOS之【属性列表】

    @implementation JamesWongViewController - (void)viewDidLoad { [superviewDidLoad]; [selfwritePerson]; ...

随机推荐

  1. linux下动态链接库.so文件 静态链接库.a文件创建及使用

    转摘网址为:http://www.cnblogs.com/fengyv/archive/2012/08/10/2631313.html Linux下文件的类型是不依赖于其后缀名的,但一般来讲:    ...

  2. WEB网页插件 如何实现 选择上传图片路径 【高级问题】

    发表于 2010-10-22 12:11 | |只看楼主       按键精灵程序里面的WEB网页插件 如何实现 选择上传图片路径 我想在上传图片的选框设置图片路径为 C:\fakepath\001. ...

  3. WebDriver 页面等待

    selenium2.4.0版本提供了页面等待处理. 显示等待元素可见: protected void WaitElementVisible(By by,int timeOutInSeconds, lo ...

  4. 【转】 C++中的new VS C语言中的malloc

    作者:gnuhpc 出处:http://www.cnblogs.com/gnuhpc/ 前几天一个朋友去面试百度空间的一个职位,被问及这个问题,我听后说了几点,不过感觉还是不透彻,所以上网查阅了一些资 ...

  5. 【poj2728】Desert King

    [poj2728]Desert King 题意 最优比率生成树. http://blog.csdn.net/ophunter_lcm/article/details/10113817 分析 Dinke ...

  6. 【NOIP 2016】斗地主

    题意 NOIP 2016 斗地主 给你一些牌,按照斗地主的出牌方式,问最少多少次出完所有的牌. 分析 这道题的做法是DFS. 为了体现这道题的锻炼效果,我自己写了好多个代码. Ver1 直接暴力搞,加 ...

  7. robotframework笔记26

    测试数据文档工具(Testdoc) Testdoc是机器人框架内置的工具生成高水平 根据测试用例文档. 创建的文档是在HTML中 格式和它包括名称.文档和其他元数据 测试套件和测试用例,以及和他们的顶 ...

  8. SharePoint Web service and template

    SharePoint Web service对应的映射列表 WSS Web   Services Web Reference Administration   Service http://<s ...

  9. CSS 声明( Declarations )

    CSS 声明1可以为空,或者由 CSS 特性( property ),后加一个冒号 ":",跟着是一个特性的值构成.中间可以有空格将它们隔开. 可用以下方式表达: property ...

  10. FaceBook Twitter实习生简历求内推

    写在博客里面吧. 有一个朋友,男,博士在读,研究方向为图像处理,计算机视觉相关. 想在在读期间有一些海外实习经历.不知道哪位博友,有相关的人脉,求内推啊.内推成功的话请吃大餐,哈哈!