XML code of spinner:
<Spinner
android:id="@+id/mySpinner"
https://stackoverflow.com/questions
style="@style/Widget.AppCompat.DropDownItem.Spinner"
android:layout_width="match_parent"
android:layout_height="70dp" />`
.kotlin:
val myStrings = arrayOf("One", "Two" , "Three", "Four")
mySpinner.adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, myStrings)
mySpinner.onItemSelectedListener = object :
AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
TODO("not implemented")
//To change body of created functions use File | Settings | File Templates.
}
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
TODO("not implemented")
//To change body of created functions use File | Settings | File Templates.
}
}}
Equal to the "hint" option in Edittext, I need a default text in a Spinner.
Spinner
. You can make your first element as hint like "Select" or whatever you need . Other option that you need to customized theSpinner
. – Fingerprintandroid:prompt
? – Latin