Une boîte de dialogue de recherche de saisie semi-automatique qui utilise l'API Places de Google pour trouver des résultats.
La boîte de dialogue recherche des emplacements dans le monde entier. Pour le personnaliser, définissez les nouvelles limites d'emplacement à l'aide de .setLatLngBounds(BOUNDS)
PlaceSearchDialog nécessite la clé API Places de Google. Vous pouvez l'obtenir à partir d'ici.
Utiliser la boîte de dialogue telle quelle
PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog . Builder ( this )
. setLocationNameListener ( new PlaceSearchDialog . LocationNameListener () {
@ Override
public void locationName ( String locationName ) {
//set textview or edittext
}
})
. build ();
placeSearchDialog . show ();
ou personnalisez-le en conséquence
PlaceSearchDialog placeSearchDialog = new PlaceSearchDialog . Builder ( this )
. setHeaderImage ( R . drawable . dialog_header )
. setHintText ( "Enter location name" )
. setHintTextColor ( R . color . light_gray )
. setNegativeText ( "CANCEL" )
. setNegativeTextColor ( R . color . gray )
. setPositiveText ( "SUBMIT" )
. setPositiveTextColor ( R . color . red )
. setLatLngBounds ( BOUNDS )
. setLocationNameListener ( new PlaceSearchDialog . LocationNameListener () {
@ Override
public void locationName ( String locationName ) {
//set textview or edittext
}
})
. build ();
placeSearchDialog . show ();
Ajoutez ceci dans vos applications AndroidManifest.xml
< meta-data android : name = " com.google.android.geo.API_KEY "
android : value = " YOUR_API_KEY " />
Utilisez-le simplement comme dépendance dans le fichier build.gradle de votre application
dependencies {
compile ' com.codemybrainsout.placesearchdialog:placesearch:1.0.1 '
}
Assurez-vous de disposer d'une version Android-maven-plugin prenant en charge les archives aar et ajoutez la dépendance suivante :
< dependency >
< groupId >com.codemybrainsout.placesearchdialog</ groupId >
< artifactId >placesearch</ artifactId >
< version >1.0.0</ version >
< type >pom</ type >
</ dependency >
Ce projet a été initié par Code My Brains Out . Vous pouvez contribuer à ce projet en soumettant des problèmes ou/et en créant ce dépôt et en envoyant une pull request.
Suivez-nous sur :
Auteur : Rahul Juneja
Copyright (C) 2016 Code My Brains Out
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.