我正在使用 Google 的自动完成位置小部件。我注意到,当我将它放在我的活动中并单击它时,它会在我的活动顶部打开一个片段(虽然我的活动是全屏的,但有一个状态栏)
如何将整个行为嵌入到我的活动中,以便单击以启动搜索的小部件实际上是填充了建议的同一个小部件
<androidx.cardview.widget.CardView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="@null"
app:layout_constraintBottom_toBottomOf="@+id/ibLocationAction"
app:layout_constraintEnd_toStartOf="@+id/ibLocationAction"
app:layout_constraintStart_toEndOf="@+id/ibClose"
app:layout_constraintTop_toTopOf="@+id/ibLocationAction">
<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.cardview.widget.CardView>
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
Log.i(GlobalVar.TAG, "Place: " + place.getName());
chosenPlace = place;
}
@Override
public void onError(Status status) {
Log.i(GlobalVar.TAG, "An error occurred: " + status);
}
});