android– 如何使用anko微调器?

android– 如何使用anko微调器?,第1张

概述我正在尝试使用anko在警报中添加一个微调器.到目前为止,我的代码如下所示:alert(getString(R.string.alert)){positiveButton("Cool"){toast("Yess!!!")}customView{linearLayout{textView("I'mat

我正在尝试使用anko在警报中添加一个微调器.到目前为止,我的代码如下所示:

alert(getString(R.string.alert)) {            positivebutton("Cool") { toast("Yess!!!") }            customVIEw {                linearLayout {                    textVIEw("I'm a text")                    padding = dip(16)                    orIEntation = linearLayout.VERTICAL                    spinner(R.style.Widget_AppCompat_Spinner) {                        ID = R.ID.spinner_todo_category                        prompt = "Select a category"                    }                }            }        }.show()

但我得到编译错误,因为显然不是如何调用微调器.我一直在看文件(Anko GitHub Wiki),但它没有提到纺纱厂.

提前致谢

解决方法:

一个解决方案

class AddActivity : AppCompatActivity() {    overrIDe fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        val items = listof(FrIEnd("bla","bla",50),FrIEnd("bla","bla",50));        val adapterFrIEnds = ArrayAdapter(this,R.layout.mon_spinner,items)        verticalLayout {            val frIEnds = spinner {  adapter = adapterFrIEnds  }            val wine = editText()            button("Say Hello") {                onClick { toast("Hello, ${wine.text}!") }            }        }    }}

使用此布局(mon_spinner.xml):

<TextVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="wrap_content"    androID:padding="10dp"    androID:textSize="14sp"    androID:textcolor="@color/colorPrimary"    androID:spinnerMode="dialog"    androID:text="XXX"    />

没关系 !!

总结

以上是内存溢出为你收集整理的android – 如何使用anko微调器?全部内容,希望文章能够帮你解决android – 如何使用anko微调器?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1118470.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存