コード例 #1
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   // TODO Auto-generated method stub
   ViewHodler hodler = new ViewHodler();
   if (!isSeacher) {
     String cityName = cityEntitys.get(position).getCity_name();
     if (cityName.length() == 1) {
       convertView = LayoutInflater.from(context).inflate(R.layout.city_list_item, null);
       hodler.tv_index = (TextView) convertView.findViewById(R.id.indexTv);
     } else {
       convertView = LayoutInflater.from(context).inflate(R.layout.citys_list_item, null);
       hodler.tv_cityName = (TextView) convertView.findViewById(R.id.tv_cityname);
     }
     CityEntity cityEntity = cityEntitys.get(position);
     if (cityName.length() == 1) {
       hodler.tv_index.setText(cityEntity.getCity_name());
     } else {
       hodler.tv_cityName.setText(cityEntity.getCity_name());
     }
   } else {
     if (convertView != null) {
       convertView = null;
     }
     convertView = LayoutInflater.from(context).inflate(R.layout.citys_list_item, null);
     TextView tv_cityName = (TextView) convertView.findViewById(R.id.tv_cityname);
     CityEntity cityEntity = cityEntitys.get(position);
     if (cityEntity.getCity_name().length() > 1) {
       tv_cityName.setText(cityEntity.getCity_name());
     }
   }
   return convertView;
 }
コード例 #2
0
 private void initSomeList() {
   cityNames = new ArrayList<String>();
   for (CityEntity entity : cityEntitys) {
     cityNames.add(entity.getCity_name());
   }
 }