How to change placeholder text in an autocomplete activity of android google place?

Viewed 9537
8 Answers
    //places auto complete

    String apiKey = getString(R.string.api_key);

    /**
     * Initialize Places. For simplicity, the API key is hard-coded. In a production
     * environment we recommend using a secure mechanism to manage API keys.
     */
    if (!Places.isInitialized()) {
        Places.initialize(getApplicationContext(), apiKey);
    }

// Create a new Places client instance. PlacesClient placesClient = Places.createClient(this);

    // Initialize the AutocompleteSupportFragment.
    AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)
            getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);

    autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG));
    autocompleteFragment.setHint("Set Drop off");

If you are using an auto complete text view, use setHint on the layout control, and the top-left title and hint text will both update. If you just update the contained edit view, the top-left title will not change.

Related