android表格效果--ListView隔行变色

首先继承SimpleAdapter

?
package meetweb.net.util; import java.util.List; import java.util.Map; import android.content.Context; import android.graphics.Color; import android.view.View; import android.view.ViewGroup; import android.widget.SimpleAdapter; public class SpecialAdapter extends SimpleAdapter { private int [] colors= new int []{ 0x30FF0000 , 0x300000FF }; //这里没有引用进去使用,只是简单引用数组运算 public SpecialAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int [] to) { super (context, data, resource, from, to); } @Override public View getView( int position ,View convertView,ViewGroup parent){ View view= super .getView(position, convertView, parent); int colorPos=position%colors.length; if (colorPos== 1 ) view.setBackgroundColor(Color.argb( 250 , 255 , 255 , 255 )); //颜色设置 else view.setBackgroundColor(Color.argb( 255 , 224 , 243 , 250 )); //颜色设置
?
return view; } }

 第二,使用重载的Adapter来达到效果

import meetweb.net.util.SpecialAdapter;
。。。。。

private SpecialAdapter simpleAdapter = null;

public void ShowData(){
RateList = rateService.findAll();
System.out.println(RateList);
LVrate=(ListView) this.findViewById(R.id.lvrate);
simpleAdapter = new SpecialAdapter(this, RateList, R.layout.accuratelistitem, new String[]{"yearlimit","year1","year2"},
new int[]{R.id.tv_yearlimit,R.id.tv_year1,R.id.tv_year2});
LVrate.setAdapter(simpleAdapter);
//listView.setOnItemClickListener(listener);
}

其实主要是需要重载SimpleAdapter,本人引用网络观点进行编写

更多相关文章

  1. android充电指示灯颜色修改
  2. TextInput 需要注意的点
  3. Android(安卓)颜色过渡计算
  4. android 按钮变化颜色
  5. Android(安卓)的res/values/colors自定义颜色列表和注释表及布局
  6. Android(安卓)TestView文本文字修改实例
  7. Android(安卓)实现颜色渐变的一个小 tip
  8. 【Android】Support兼容包详解
  9. Android(安卓)LCD背景颜色和边框颜色的可控制

随机推荐

  1. android系统中运行jar文件
  2. android 部分网址 https连接不上(Not tru
  3. 浅析Android中Handler机制
  4. Android(安卓)build.prop生成过程
  5. 约束布局ConstraintLayout的使用你知道吗
  6. 轻量级 Web 组件编译器 — Stencil
  7. PHP 使用钉钉发送群消息
  8. 彩虹发卡网源码+企业级发卡网源码+个人发
  9. 基于Vue的极简生成器 — Vuepress
  10. 飞舞的小球演示