有谁知道为什么我每次点击搜索栏都会失去焦点?

时间:2019-04-11 01:13:29

标签: java android searchbar

每次单击我的自动完成片段都会失去焦点。

我已启用google place API并检查了我的凭据,但一切仍然不起作用,我在日志“ E / SchedPolicy:set_timerslack_ns写入失败:不允许操作”中收到此错误

public class Main extends AppCompatActivity implements OnMapReadyCallback 
{
  private GoogleMap mMap;
  PlaceAutocompleteFragment placeAutoComplete;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    //Sets the bottom navigation bar at the bottom.
    BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

    //Search bar for the map to search for location.

    placeAutoComplete = (PlaceAutocompleteFragment)getFragmentManager().findFragmentById(R.id.place_autocomplete);
    placeAutoComplete.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {

            Log.d("Maps", "Place selected: " + place.getName());
        }

        @Override
        public void onError(Status status) {
            Log.d("Maps", "An error occurred: " + status);
        }
    });

    SupportMapFragment mapFragment1 = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment1.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

}

从技术上讲,当我单击搜索栏时,它应该允许我键入地点并进行搜索,然后重新定位。

0 个答案:

没有答案