{"id":21130065,"url":"https://github.com/seatgeek/android-PlacesAutocompleteTextView","last_synced_at":"2025-07-09T01:32:16.209Z","repository":{"id":33311966,"uuid":"36956708","full_name":"seatgeek/android-PlacesAutocompleteTextView","owner":"seatgeek","description":"An address-autocompleting text field for Android","archived":false,"fork":false,"pushed_at":"2021-06-01T15:44:07.000Z","size":5374,"stargazers_count":281,"open_issues_count":7,"forks_count":102,"subscribers_count":110,"default_branch":"main","last_synced_at":"2024-04-13T17:08:42.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seatgeek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-05T21:39:40.000Z","updated_at":"2024-01-09T10:46:51.000Z","dependencies_parsed_at":"2022-08-24T16:01:09.427Z","dependency_job_id":null,"html_url":"https://github.com/seatgeek/android-PlacesAutocompleteTextView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatgeek%2Fandroid-PlacesAutocompleteTextView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatgeek%2Fandroid-PlacesAutocompleteTextView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatgeek%2Fandroid-PlacesAutocompleteTextView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatgeek%2Fandroid-PlacesAutocompleteTextView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seatgeek","download_url":"https://codeload.github.com/seatgeek/android-PlacesAutocompleteTextView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476376,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T05:32:14.395Z","updated_at":"2024-11-20T05:32:20.352Z","avatar_url":"https://github.com/seatgeek.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# android-PlacesAutocompleteTextView\n\n[![Build Status](https://travis-ci.org/seatgeek/android-PlacesAutocompleteTextView.svg)](https://travis-ci.org/seatgeek/android-PlacesAutocompleteTextView) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-PlacesAutocompleteTextView-green.svg?style=true)](https://android-arsenal.com/details/1/2777)\n\nAn AutocompleteTextView that interacts with the [Google Maps Places API](https://developers.google.com/places/web-service/autocomplete)\nto provide location results and caches selected results in a history file for later use\n\n![gif](resources/autocomplete.gif)\n\n### Installing\n\nThe `PlacesAutocompleteTextView` is available from the sonatype snapshots repository.\nUse the following in your `build.gradle`:\n\n```groovy\nrepositories {\n    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }\n}\n\ndependencies {\n    compile 'com.seatgeek:placesautocomplete:0.3-SNAPSHOT'\n}\n```\n\n### Basic setup and usage\n\n1. You'll need a Google Server API key for you application. There are instructions on how to set up your API project and generate a key [here](https://developers.google.com/places/web-service/get-api-key)\n\n2. Your application will need the `android.permission.INTERNET` permission in its manifest for the\nView to interact with the Google Maps API\n\n3. With your API key, you're ready to add the `PlacesAutocompleteTextView` to your layout xml:\n\n    ```xml\n   \u003ccom.seatgeek.placesautocomplete.PlacesAutocompleteTextView\n       android:id=\"@+id/places_autocomplete\"\n       android:layout_width=\"match_parent\"\n       android:layout_height=\"wrap_content\"\n       app:pacv_googleMapsApiKey=\"\u003cYOUR_GOOGLE_API_KEY\u003e\"/\u003e\n    ```\n4. Finally, you'll likely want a listener in your UI to know when the user has selected an item from the dropdown:\n\n    ```java\n   placesAutocomplete.setOnPlaceSelectedListener(\n           new OnPlaceSelectedListener() {\n               @Override\n               public void onPlaceSelected(final Place place) {\n                  // do something awesome with the selected place\n               }\n           }\n   );\n    ```\n5. That's it!\n\n_Note: you can treat the `PlacesAutocompleteTextView` the same as any `AutocompleteTextView`\nas it extends from the framework `AutocompleteTextView`. This means you can use\ncustom styles with all the standard view properties._\n\n### Advanced usage/customization\n\n#### XML properties\n\nThere are a few XML properties that can control some of the functionality of the autocomplete view:\n\nxml property | java method | description\n--- | --- | ---\n`pacv_historyFile` | `setHistoryManager()` | By default, the `PlacesAutocompleteTextView` will save the history of the selected `Place`'s in a file on the file system. This is great for cases when your user may be typing in the same address in different parts of your UI or across different sessions. If you'd like to simply change the location of the file on the filesystem, you can specify the path string here. By default, the file is stored in the application cache dir under `autocomplete/pacv_history.json`. If this is a feature that you'd like to disable, you can set the property in xml to `@null` or call `setHistoryManager(null)`.\n`pacv_resultType` | `setResultType()` | The Places API can return various types of `Place`s depending on what your application is looking to allow the user to select. By default, the `PlacesAutocompleteTextView` only requests items of type `address`, which returns locations associated with a full postal address, public or residential. You can change this to also be `geocode` for any address or `establishment` for non-residential addresses\n`pacv_adapterClass` | `setAdapter()` | If you don't like the default `Adapter` for displaying the items in the dropdown list (it is pretty basic by default), you can override it by specifying your own in xml (by passing the fully-qualified classname) or using `setAdapter()`. An important note: because of how the filtering functionality works in the `PlacesAutocompleteTextView`, your custom adapter must extend `AbstractPlacesAutocompleteAdapter`.\n`pacv_clearEnabled` | `showClearButton()` | Show the typicall X button to the right of the `PlacesAutocompleteTextView` to let user clear the text. Defaults to false. Other methods for controlling the clear button is `setImgClearButton()` Override the default Clear image and add your own, `setOnClearListener()` Override the clear listener like what should happen when the X is pressed, default is clear text, `showClearButton()` show/hide it.\n\n#### Need more details? `PlaceDetails`\n\nOne of the requirements of our usage of this view was autofilling the payment and shipping addresses\nin our checkout flow. By default, the returned `Place` from the Google Maps API doesn't have the\nfull set of address components (city, state, postal, street address, etc.) and instead provides it\n\"conveniently\" in a human readable string like \"235 Park Ave South, New York, NY 10003\". Which is\nprobably pretty tricky to parse to get the address components. Enter the\n[\"Place Details\" API](https://developers.google.com/places/web-service/details). The\n`PlacesAutocompleteTextView` provides a helper method `getDetailsFor(Place, DetailsCallback)` that\nyou can use to easily fetch the extra details that you might need. The `PlaceDetails` object has a\nlot more than just address components as well, so if you're building a complex UI around a location,\nthis is probably the API call that you'll need to make.\n\nIf you have concerns about configuration changes while the details request is in-flight, you can\ngrab the instance of the `PlacesApi` from `PlacesAutoCompleteTextView#getApi()` and manage the\ndetails request yourself.\n\nSee the example project for this API in use.\n\n#### Getting stylish\n\nThe `PlacesAutocompleteTextView` is styleable using the `pacv_placesAutoCompleteTextViewStyle`\nglobal style attribute. The style should extend from `PACV.Widget.PlacesAutoCompleteTextView` to\nget the default style's parameters, e.g.:\n\n`styles.xml`:\n```xml\n        \u003cstyle name=\"Widget.PlacesAutoCompleteTextView.Styled\"\n               parent=\"PACV.Widget.PlacesAutoCompleteTextView\"\u003e\n            \u003citem name=\"android:background\"\u003e@drawable/my_edit_text_background\u003c/item\u003e\n            \u003citem name=\"android:textAppearance\"\u003e@style/MyTextAppearance\u003c/item\u003e\n        \u003c/style\u003e\n```\n\n`themes.xml`:\n```xml\n        \u003cstyle name=\"AppTheme\" parent=\"@style/YourParentStyle\"\u003e\n            \u003citem name=\"pacv_placesAutoCompleteTextViewStyle\"\u003e@style/Widget.PlacesAutoCompleteTextView.Styled\u003c/item\u003e\n        \u003c/style\u003e\n```\n\n#### Location biasing\n\nA common thing that you might want to do is bias the place results to the location of the user.\nBy default, the `PlacesAutocompleteTextView` will bias the results by a geoip lookup of\nthe device's IP address. If your app has different requirements for where you want to bias the\naddress results to or you want more accuracy than a geoip lookup, you can pass an Android\n`Location` into the `PlacesAutocompleteTextView` using the `#setCurrentLocation()` method.\n\nYou can tweak the biasing radius by using the `setRadiusMeters(Long)` method.\n\nIf you'd like to disable biasing completely, you can `setLocationBiasEnabled(false)`\n\n### Purpose and \"why not use Google Play Services?\"\n\nThis project was started internally before the Places API was released on Google Play Services and\nwe needed a way to make entering your payment and shipping addresses in our Android app easier. The\nreason that this project is still alive and hasn't migrated to Google Play Services is twofold:\n\n  0. It's still impossible to fetch the full `PlaceDetails` from the Google Play Services\n  implementation [\\[ref\\]](https://developers.google.com/places/android-api/place-details), without\n  which you cannot get the full breakdown of address components\n  0. It handles hooking the UI components to the data for you to accelerate your development\n  process. With Google Play Services you still need to create your own `FilterAdapter`,\n  `AutocompleteTextView`, etc.\n\n### Contributing\n\n0. Fork this repo and clone your fork\n0. Make your desired changes\n0. Add tests for your new feature and ensure all tests are passing\n0. Commit and push\n0. Submit a Pull Request through Github's interface and a project maintainer will\ndecide your change's fate.\n\n_Note: issues can be submitted via [github issues](https://github.com/seatgeek/android-PlacesAutocompleteTextView/issues/new)_\n\n### License\n\nPlacesAutocompleteTextView is released under a [BSD 2-Clause License](http://opensource.org/licenses/BSD-2-Clause), viewable [here](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseatgeek%2Fandroid-PlacesAutocompleteTextView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseatgeek%2Fandroid-PlacesAutocompleteTextView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseatgeek%2Fandroid-PlacesAutocompleteTextView/lists"}