0
我有兩個不同的textView
,一個用於出發和着陸。當用戶快速地在textView
的谷歌PlaceAutoComplete
活動中打開一個新窗口並且用戶選擇出發目的地。對於登陸同樣的事情發生。問題是我希望能夠爲每個textView
設置不同的目的地。感謝您的幫助.........使用相同的placeAutocomplete函數來設置兩個不同的textView值
public void onClick(View v) {
if (v == mDeparture) {
openAutocompleteActivity();
}
if (v == mLanding) {
openAutocompleteActivity();
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_AUTOCOMPLETE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
mDeparture.setText(place.getAddress());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.e(TAG, "Error: Status = " + status.toString());
} else if (resultCode == RESULT_CANCELED) {
}
}
}
private void openAutocompleteActivity() {
try {
Intent intent = newPlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.build(this);
startActivityForResult(intent, REQUEST_CODE_AUTOCOMPLETE);
} catch (GooglePlayServicesRepairableException e) {
GoogleApiAvailability.getInstance().getErrorDialog(this, e.getConnectionStatusCode(),
0 /* requestCode */).show();
} catch (GooglePlayServicesNotAvailableException e) {
String message = "Google Play Services is not available: " +
GoogleApiAvailability.getInstance().getErrorString(e.errorCode);
}
}