首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

listview item 背景更迭变换

2012-09-25 
listview item 背景交替变换private static int[] mColors { R.drawable.itembg2, R.drawable.itembg1 }

listview item 背景交替变换

private static int[] mColors = { R.drawable.itembg2, R.drawable.itembg1 };//要改变的背景public class AltColorAdapter extends SimpleAdapter {                       public AltColorAdapter(Context context,                List<? extends Map<String, ?>> data, int resource, String[] from,                int[] to) {            super(context, data, resource, from, to);            // TODO Auto-generated constructor stub        }        @Override        public View getView(int position, View convertView, ViewGroup parent) {            // TODO Auto-generated method stub            int[] arrayOfInt = mColors;            int colorLength = mColors.length;            int selected = arrayOfInt[position % colorLength];            View localView = super.getView(position, convertView, parent);            localView.setBackgroundResource(selected);            return localView;        }    }

?

热点排行