https://github.com/remylavergne/spinner-android
A simple API for Android Spinner widget.
https://github.com/remylavergne/spinner-android
android android-library kotlin kotlin-android kotlin-library
Last synced: 3 months ago
JSON representation
A simple API for Android Spinner widget.
- Host: GitHub
- URL: https://github.com/remylavergne/spinner-android
- Owner: remylavergne
- License: mit
- Created: 2019-09-25T19:43:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-29T09:49:18.000Z (over 5 years ago)
- Last Synced: 2025-01-24T15:43:20.487Z (5 months ago)
- Topics: android, android-library, kotlin, kotlin-android, kotlin-library
- Language: Kotlin
- Homepage:
- Size: 7.43 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://jitpack.io/#remylavergne/spinner-android)
# Spinner
Spinner API écrite en Kotlin.
## Screenshots / gifs
* Simplest behaviour
[]
* Add hint to list
[]
* Add a hint not selectable, only in spinner
[]
## Install
**Step 1.** Add the JitPack repository to your build file
```groovy
allprojects {
repositories {
...
maven {
url 'https://jitpack.io'
}
}
}
```**Step 2.** Add the dependency
```groovy
dependencies {
implementation 'com.github.remylavergne:spinner-android:v0.3'
}
```## Ajouter dans la vue dans le layout
```xml
```
Options disponibles :
| Attrs | Fonction | Type | Défaut |
|----------|:-------------|:-----------:|:----:|
| **spinner_hint** | Change le texte qui s'affiche à l'initialisation du Spinner | string | null
| **spinner_hint_selectable** | Permet de sélectionner, ou pas, le hint de la liste | boolean | true
| **spinner_hint_toast_message** | Si le Spinner est présent, et qu'on ne peut pas le sélectionner, nous pouvons afficher un message Toast | string | null
| **spinner_dialog_show_hint** | Afficher le **hint** dans la liste du **Dialog** | boolean | true
| **spinner_title** | Change le titre du **Dialog** | string | null
| **spinner_button** | Changer le texte du bouton de fermeture de la **Dialog** | string | Generic button
| **spinner_custom_layout** | Changer le layout du **Dialog** | reference | android.R.layout.simple_list_item_1### Higher Order Function
```kotlin
// Binding de la vue
this._mySpinner = findViewById(R.id.my_spinner)// Configuration du Spinner
this._mySpinner.set {
adapter(
listOf(
"Element 01",
"Element 02",
"Element 03",
"Element 04",
"Element 05",
"Element 06",
"Element 07",
"Element 08",
"Element 09",
"Element 10"
)/*, R.layout.custom_layout*/
)// Applique un thème à la liste du Dialog
listCustomLayout(R.layout.custom_layout)// Listener pour tous les changements
setItemSelectedListener(object : Spinner.ISpinner {
override fun onItemSelected(item: String) {
val sentence = "Choix : $item"
_result.text = sentence
}
})// Ajoute un hint à la liste d'objets, et désactive sa sélection
hint("Hint in High Order Function", false, "Unable")
// Affiche le hint dans la liste du Dialog
showHintInList(true)
// Change le titre du Dialog
title("Title in High Order Function")
// Change le text du bouton du Dialog
buttonText("Close with HOF")
}
```