小编eye*_*ler的帖子

如何在微调器中添加提示

微调器的XML代码:

<Spinner
    android:id="@+id/mySpinner"
    https://stackoverflow.com/questions       
    style="@style/Widget.AppCompat.DropDownItem.Spinner"
    android:layout_width="match_parent"
    android:layout_height="70dp" />`
Run Code Online (Sandbox Code Playgroud)

.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.
    }
}}
Run Code Online (Sandbox Code Playgroud)

等于Edittext中的“提示”选项,我需要Spinner中的默认文本。

android android-spinner kotlin

6
推荐指数
1
解决办法
5474
查看次数

标签 统计

android ×1

android-spinner ×1

kotlin ×1