2012-11-01 2 views
0

나는 매우 새로운 안드로이드 Google지도를 원합니다. 사용자가 내 프로그램에서 편집 텍스트를 클릭 할 때 Google지도 장소에서 자동 제안을 제공하고 싶습니다.안드로이드에 대한 자동 Sugessions 제공 Google지도 palces

MainActivity를 : 해당 사용자가 한 곳을 선택할 수 있도록 H 관련 장소 디스플레이를 대응하는이 코드 내 응용 프로그램에서 실행이

+0

이 링크를 따라? –

+0

:

public class HttpHelper { HttpManager httpCall; private static final String TAG = "GooglePlacesApi"; private Context mContext; public HttpHelper(Context context) { mContext = context; httpCall = new HttpManager(); } public ArrayList<String> getAutocompletePlaces(String placeName) { String response2 = ""; ArrayList<String> autocompletPlaceList = new ArrayList<String>(); String url = Constants.GOOGLE_PLACE_AUTOCOMPLETE_URL + "input=" + placeName + "&sensor=false&key=" + Constants.GOOGLE_PLACE_API_KEY; Log.e("MyAutocompleteURL", "" + url); try { response2 = httpCall.connectToGoogleServer(url); JSONObject jsonObj = (JSONObject) new JSONTokener(response2.trim() .toString()).nextValue(); JSONArray results = (JSONArray) jsonObj.getJSONArray("predictions"); for (int i = 0; i < results.length(); i++) { Log.e("RESULTS", "" + results.getJSONObject(i).getString("description")); autocompletPlaceList.add(results.getJSONObject(i).getString( "description")); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return autocompletPlaceList; } } 
user1787493

답변

0

을 달성 할 수있는 방법 좀 도와주세요 -

mAtv_DestinationLocaiton = (AutoCompleteTextView) findViewById(R.id.et_govia_destination_location); 

mAtv_DestinationLocaiton.addTextChangedListener(new TextWatcher() { 

      public void onTextChanged(CharSequence s, int start, int before, 
        int count) { 
       Log.i("Count", "" + count); 
       if (!mAtv_DestinationLocaiton.isPerformingCompletion()) { 
        autocompletePlaceList.clear(); 
        DestiClick2 = false; 
        new loadDestinationDropList().execute(s.toString()); 
       } 
      } 
      public void beforeTextChanged(CharSequence s, int start, int count, 
        int after) { 
       // TODO Auto-generated method stub 
      } 
      public void afterTextChanged(Editable s) { 
       // TODO Auto-generated method stub 
      } 
     }); 
    } 

    private class loadDestinationDropList extends 
      AsyncTask<String, Void, ArrayList<String>> { 
     @Override 
     protected void onPreExecute() { 
      // Showing progress dialog before sending http request 
      destinationProgBar.setVisibility(View.VISIBLE); 
     } 

     protected ArrayList<String> doInBackground(String... unused) { 

      try { 
       Thread.sleep(3000); 
      } catch (InterruptedException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 
      autocompletePlaceList = httpHelper 
        .getAutocompletePlaces(mAtv_DestinationLocaiton.getText() 
          .toString()); 

      return autocompletePlaceList; 
     } 

HttpHelper 클래스 : -

내가 placematrix API를 사용하여 위치를 표시 할 http://android.foxykeep.com/dev/how-to-add-autocompletion-to-an-edittext
+0

여기에서 ur는 http의 연결을 위해 모든 jar 파일을 사용합니까? – user1787493

+0

.jar 파일을 사용하지 않고 자세한 내용은 Google Direction API를 사용하십시오. – ckpatel

+0

autocompletePlaceList이게 뭐죠? – user1787493