【问题标题】:I need to add input in List, with button, in Kotlin我需要在 Kotlin 中使用按钮在 List 中添加输入
【发布时间】:2019-11-11 00:01:05
【问题描述】:

我想用按钮(Enter)在列表(list)中添加一些输入(newtext),在我输入此代码之前,按钮在不同的布局上,打开这个正在工作(我'确定一切都是正确的)但是在我编写了这段代码之后(特别是'私人乐趣......')它不再起作用了。你能帮我解决这个问题吗?

var list = arrayListOf<ListView>()
var newtext = findViewById<EditText>(R.id.Enter)
var Enter = findViewById<Button>(R.id.add)

Enter.setOnClickListener { list.add(newtext) }

private fun <E> ArrayList<E>.add(newtext : View) {
    TODO('not implemented") 

【问题讨论】:

    标签: android android-studio kotlin


    【解决方案1】:

    您不能在嵌套函数中创建函数private。 您可以删除 private 关键字,一切都会好起来的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 2013-02-25
      • 2018-01-15
      相关资源
      最近更新 更多