---
# System prepended metadata

title: 2020-04-20 | Kotlin | Form elements
tags: [android, kotlin, gobelins]

---

# 2020-04-20 | Kotlin | Form elements

###### tags: `kotlin` `android` `gobelins` 

## Spinner
### Variables
```kotlin
    private lateinit var adapter: ArrayAdapter<String>
    private lateinit var spinner: Spinner
    private val planetes = listOf("Mer","Vé","Terre","Ma","Ju","Sat","Ur","Nept","Plu")

```
### In onViewCreated function
```kotlin
        spinner = view.findViewById(R.id.spinner)

        adapter = ArrayAdapter(
            view.context,
            android.R.layout.simple_spinner_item,
            planetes
        )

        spinner.adapter = adapter
```
### In xml layout
```kotlin
    <Spinner
        android:id="@+id/spinner"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>
```
