@Override public View getView(int position, View convertView, ViewGroup parent) { int viewType = getItemViewType(position); MKOLSearchRecord record = getItem(position); switch (viewType) { case 0: if (convertView == null) convertView = getLayoutInflater().inflate(R.layout.item_city, null); TextView cityView = (TextView) convertView.findViewById(R.id.city); cityView.setText(record.cityName); TextView downloadedView = (TextView) convertView.findViewById(R.id.city_downloaded); downloadedView.setVisibility(isCityExisted(record.cityID) ? View.VISIBLE : View.GONE); break; case 1: if (convertView == null) convertView = getLayoutInflater().inflate(R.layout.item_province, null); TextView provinceView = (TextView) convertView.findViewById(R.id.province); provinceView.setText(record.cityName); break; } return convertView; }
/** * search offline city * * @param view */ public void search(View view) { ArrayList<MKOLSearchRecord> records = mOffline.searchCity(mCityNameView .getText().toString()); if (records == null) { return; } mCidView.setText(String.valueOf(records.get(0).cityID)); }
/** * 搜索离线城市 * * @param view */ public void search(View view) { ArrayList<MKOLSearchRecord> records = mOffline.searchCity(selectedCity); if (records == null || records.size() != 1) return; mOffline.start(records.get(0).cityID); Toast.makeText(context, "开始下载离线地图. 城市名称: " + records.get(0).cityName, Toast.LENGTH_SHORT).show(); updateView(); }
public static ArrayList<MKOLSearchRecord> getAllCities() { return mMKOfflineMap.getOfflineCityList(); }
@Override public MKOLSearchRecord getItem(int position) { return mData.get(position); }
public MKOLSearchRecord getCityInfo() { return mCityInfo; }
public void setCityInfo(MKOLSearchRecord mRecord) { this.mCityInfo = mRecord; pinyin = PinyinUtil.getPinYin(mRecord.cityName); }