@Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
    String newText = s.toString().trim();

    Inputtips inputTips =
        new Inputtips(
            PoiKeywordSearchActivity.this,
            new InputtipsListener() {

              @Override
              public void onGetInputtips(List<Tip> tipList, int rCode) {
                if (rCode == 0) { // 正确返回
                  List<String> listString = new ArrayList<String>();
                  for (int i = 0; i < tipList.size(); i++) {
                    listString.add(tipList.get(i).getName());
                  }
                  ArrayAdapter<String> aAdapter =
                      new ArrayAdapter<String>(
                          getApplicationContext(), R.layout.route_inputs, listString);
                  searchText.setAdapter(aAdapter);
                  aAdapter.notifyDataSetChanged();
                }
              }
            });
    try {
      inputTips.requestInputtips(
          newText, editCity.getText().toString()); // 第一个参数表示提示关键字,第二个参数默认代表全国,也可以为城市区号

    } catch (AMapException e) {
      e.printStackTrace();
    }
  }
Beispiel #2
0
  @Override
  public void onTextChanged(CharSequence s, int start, int before, int count) {
    // Log.e(TAG, "onTextChanged");
    // 获取当前城市,或者指定区域

    String newText = s.toString().trim();
    Inputtips inputtips =
        new Inputtips(
            this,
            new Inputtips.InputtipsListener() {

              @Override
              public void onGetInputtips(List<Tip> tipList, int rCode) {
                if (rCode == 0) { // 正确返回
                  latLonPointList = new ArrayList<LatLonPoint>();
                  List<String> listString = new ArrayList<String>();
                  for (int i = 0; i < tipList.size(); i++) {
                    listString.add(tipList.get(i).getName());
                    // 保存经纬度信息
                    latLonPointList.add(tipList.get(i).getPoint());
                  }

                  ArrayAdapter<String> aAdapter =
                      new ArrayAdapter<String>(
                          getApplicationContext(), R.layout.route_inputs, listString);
                  search_title_textview.setAdapter(aAdapter);
                  aAdapter.notifyDataSetChanged();
                }
              }
            });

    try {
      // 第一个参数表示提示关键字, 第二个参数默认代表全国, 也可以为城市区号
      inputtips.requestInputtips(newText, CityName);
    } catch (AMapException e) {
      e.printStackTrace();
    }
  }