0

私はAndroidプラットフォーム上で私の大学からカープールのアプリを開発しています。私のGoogleマップでは、2つの場所のオートコンプリート・フラグメント(「From」と「To」と呼ばれる)との乗り換えリクエストボタンがあります。アプリケーションがユーザーの現在地を知ったら、場所のオートコンプリート断片の1つを大学の場所に設定し、その断片の変更/編集を無効にする必要があります(つまり、ユーザーの所在地が大学にある場合は、ユーザーが大学以外の場所から拾い上げることを選択したくないため、フラグメントの機能を無効にします)。Google Place Autocompleteのフラグメント編集機能を制御する(有効/無効にする)

同様に、彼らの所在地が大学以外であれば、大学に乗る必要があります。したがって、2番目のフラグメント、「To」フラグメントは大学の所在地に固定する必要があります。したがって、ユーザが大学以外の場所に乗ることを要求するのを防ぐために、それを無効にする必要があります。

質問:私はPlace Autocomplete Fragmentを無効にする/有効にするにはどうすればよいですか?

私が達成しようとしていることが明確であることを願っています。どのように私がこれにアプローチすべきかの助けやアイデアを高く評価します。

次の関数はonConnected()と同様にonLocationChanged()から呼び出された:インサイド

private void handleNewLocation(Location location) { 
    Log.i(TAG, location.toString()); 

    //Place current location marker 
    LatLng currentlatLng = new LatLng(location.getLatitude(), location.getLongitude()); 

    Location university = new Location(""); 
    university.setLatitude(-33.8688); 
    university.setLongitude(151.2093); 

    float distanceInMeters = location.distanceTo(university); 
    /* 
     NOTE: this is assuming the user is rider. 
     Compute distance between current location and University, 
     if distance is >= 1000m, then set destination ("To" fragment) to University. 
     Otherwise (distance is < 1000m), set source location ("From" fragment) to University 
    */ 
    if(distanceInMeters >= 1000.0) { 
     toPlaceAutocomplete.setText("University"); 
    } else { 
     fromPlaceAutocomplete.setText("University"); 
    } 

    MarkerOptions markerOptions = new MarkerOptions(); 
    markerOptions.position(currentlatLng); 
    markerOptions.title("I am here!"); 
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); 
    mCurrLocationMarker = mGoogleMap.addMarker(markerOptions); 

    //move map camera 
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(currentlatLng)); 
    mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(11)); 
} 

フラグメントのテキストが設定されている場合ステートメントは、私が検索を無効にしたい場合。どうやってやるの?

答えて

0

AppCompatEditTextオブジェクトをPlaceAutocompleteFragmentに含めることと、AppCompatEditText.setEnabled(false)を呼び出して無効にすることができます。

PlaceAutocompleteFragment originAutocomplete= (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.originAutocomplete); 

AppCompatEditText originEditText = (AppCompatEditText) originAutocomplete.getView().findViewById(R.id.place_autocomplete_search_input); 

originEditText.setEnabled(false); 
関連する問題