我试图第一次实现地方自动完成片段并面对它的一个问题.当我开始输入时,在第一个字母后它开始搜索而不是显示结果它(片段)就消失了..我是获取是状态{statusCode = PLACES_API_ACCESS_NOT_CONFIGURED,resolution = null}
的Manifest.xml
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx4" />
Run Code Online (Sandbox Code Playgroud)
Xml_layout
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:id="@+id/Area"
android:onClick="Onselection"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_below="@+id/Area"
android:layout_alignParentStart="true" />
Run Code Online (Sandbox Code Playgroud)
类
public class test extends AppCompatActivity implements PlaceSelectionListener {
private static final String LOG_TAG = "PlaceSelectionListener";
private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
new LatLng(-85, -180), new LatLng(85, 180));
private static final int REQUEST_SELECT_PLACE = 1000;
TextView locationtext ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_testtttt);
locationtext = …Run Code Online (Sandbox Code Playgroud)