public class MyAdapter extends BaseAdapter { private LayoutInflater mlayInflater; public MyAdapter(Context context,
ArrayList<HashMap<String, Object>> listItem) {
// TODO Auto-generated constructor stub
this.mlayInflater = LayoutInflater.from(context);
} @Override
public int getCount() {
// TODO Auto-generated method stub
return listItem.size();
} @Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
} @Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
} @Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.list_views,
null);
}
TextView arriveStationName = (TextView) convertView
.findViewById(R.id.ZC_sesatList_stationName);
TextView ticketType = (TextView) convertView
.findViewById(R.id.ZC_sesatList_ticketType);
TextView seatType = (TextView) convertView
.findViewById(R.id.ZC_sesatList_seatType);
TextView flag = (TextView) convertView
.findViewById(R.id.ZC_sesatList_flag);
// 根据list的值设置
Map<String, Object> dataListMap = (Map<String, Object>) listItem
.get(position);
String ZC_arriveStationName = dataListMap.get("arriveStationName").toString();
String ZC_ticketType = dataListMap.get("ticketType").toString();
String ZC_seatType = dataListMap.get("seatType").toString();
            String ZC_flag = dataListMap.get("flag").toString();
if(ZC_flag.equals("")){
arriveStationName.setTextColor(Color.RED);
ticketType.setTextColor(Color.RED);
seatType.setTextColor(Color.RED);
flag.setTextColor(Color.RED);
}
arriveStationName.setText(ZC_arriveStationName);
ticketType.setText(ZC_ticketType);
seatType.setText(ZC_seatType);
flag.setText(ZC_flag); // 点击跳转事件
list.setOnItemClickListener(new OnItemClickListener() { @Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Map<String, Object> map = (Map<String, Object>) listItem.get(arg2);
String seatNo = map.get("seatNo").toString();
String coachNo = map.get("coachNo").toString();
String limit_stationName = map.get("limit_stationName")
.toString();
String board_stationName = map.get("board_stationName")
.toString();
String arriveStationName = map.get("arriveStationName")
.toString();
String ticketType = map.get("ticketType").toString();
String seatTypeNo = map.get("seatTypeNo").toString();
String seatType = map.get("seatType").toString();
String flag = map.get("flag").toString();
Intent intent = new Intent(
zc_xiweiguanli_chexiang_seatlist.this,
zc_xiweiguanli_chexiang_seatDetails.class);
intent.putExtra("seatNo", seatNo);
intent.putExtra("coachNo", coachNo);
intent.putExtra("limit_stationName", limit_stationName);
intent.putExtra("board_stationName", board_stationName);
intent.putExtra("arriveStationName", arriveStationName);
intent.putExtra("ticketType", ticketType);
intent.putExtra("seatTypeNo", seatTypeNo);
intent.putExtra("seatType", seatType);
intent.putExtra("flag", flag);
startActivity(intent);
zc_xiweiguanli_chexiang_seatlist.this.finish();
} });
return convertView;
}
}反复调用getview而且数据超过100就会空指针....颜色放置后发现所有的都变成红色了