地点自动完成正在打开一个新的叠加层 google 搜索
Places auto complete is opening a new overlay google search
我正在使用 Google 的自动完成地点小部件。我注意到,当我将它放在我的 activity 中并单击它时,它会在我的 activity 顶部打开一个片段(虽然我的 activity 是全屏的,但它有一个状态栏)
如何将整个行为嵌入到我的 activity 中,以便单击以启动搜索的小部件实际上是填充有建议的同一个小部件
<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);
}
});
根据 Place Autocomplete 文档 here,您可以在覆盖模式下使用自动完成小部件(这称为 "MODE_OVERLAY"),或者您可以在全屏模式下有自动完成小部件(这称为 MODE_FULLSCREEN )。
我刚开始接触place autocomplete的时候也遇到了这个问题,但是貌似不能和你的pressed view交互,只能在MODE_FULLSCREEN和MODE_OVERLAY 正如我上面提到的(全部根据文档)
我正在使用 Google 的自动完成地点小部件。我注意到,当我将它放在我的 activity 中并单击它时,它会在我的 activity 顶部打开一个片段(虽然我的 activity 是全屏的,但它有一个状态栏)
如何将整个行为嵌入到我的 activity 中,以便单击以启动搜索的小部件实际上是填充有建议的同一个小部件
<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);
}
});
根据 Place Autocomplete 文档 here,您可以在覆盖模式下使用自动完成小部件(这称为 "MODE_OVERLAY"),或者您可以在全屏模式下有自动完成小部件(这称为 MODE_FULLSCREEN )。
我刚开始接触place autocomplete的时候也遇到了这个问题,但是貌似不能和你的pressed view交互,只能在MODE_FULLSCREEN和MODE_OVERLAY 正如我上面提到的(全部根据文档)