本节课主要讲解新闻客户端新闻分类界面的新闻分类背景更换设计思路。
主要的技术方法是复写SimpleAdapter类。
效果图
课程下载
下载地址:http://115.com/file/e77sbtoi
关键代码
package com.szy.news.custom; import java.util.List; import java.util.Map; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.SimpleAdapter; import android.widget.TextView; import com.szy.news.activity.R; /** *@author coolszy *@date 2012-2-27 *@blog http://blog.92coding.com */ public class CustomSimpleAdapter extends SimpleAdapter { public CustomSimpleAdapter(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 v = super.getView(position, convertView, parent); //更新第一个TextView的背景 if (position==0) { TextView categoryTitle = (TextView)v; categoryTitle.setBackgroundResource(R.drawable.categorybar_item_background); categoryTitle.setTextColor(0XFFFFFFFF); } return v; } }