0
私はこのコードを使用してアドレスを取得します。代わりにEditTextを使用する方法オートコンプリート用のフラグメント?
フィールドとしてEditTextのような単純な要素を使用し、フラグメントは使用しません。手段、私はのEditTextをクリックした場合
の下に、私は2つのフィールド(フィールド1アドレスのホーム、一例として、住所オフィス用フィールド2)を必要とするように、オートコンプリートのポップアップウィンドウが、呼ばれるべき
私は、コードを変更する必要があり?
txt_lat = (TextView) findViewById(R.id.txt_lat);
txt_lon = (TextView) findViewById(R.id.txt_lon);
editText = (EditText) findViewById(R.id.editText1);
progressBar = (ProgressBar) findViewById(R.id.progressBar_anno_add_adress);
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
progressBar.setVisibility(View.VISIBLE);
Log.i("TAG", "Place: " + place.getName());
LatLng latLng = place.getLatLng();
txt_lat.setText(String.valueOf(latLng.latitude));
txt_lon.setText(String.valueOf(latLng.longitude));
editText.setText(place.getName());
progressBar.setVisibility(View.GONE);
loc_lat=String.valueOf(latLng.latitude);
loc_lon=String.valueOf(latLng.longitude);
loc_adress=place.getName().toString();
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Log.i("TAG", "An error occurred: " + status);
}
});
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
私はEditTextsを使いたいので、(私は、TextFieldを必要としません。