Kotlin数据类型不匹配错误

时间:2017-11-09 14:46:39

标签: kotlin

错误消息如下:

  

"类型不匹配    kotlin.collections.ArrayList   发现   () - > kotlin.collections.ArrayList"

尝试创建对象时。

public class PhotoController : Typed2EpoxyController<ArrayList<TowerOrUnitData>, Boolean>() {

  override fun buildModels(activityData: ArrayList<TowerOrUnitData>?, data2: Boolean?) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.

    activityData!!.forEach {

      val activityDataArrayList:ArrayList<ActivityData>

      for (i in 1..5) {
        activityDataArrayList.add(ActivityData("activityName" + i,"activityStatus" + i,"70","25","Open x|Close y|For Review z"))
      }

      TowerOrUnitData{"nil";"nil";activityDataArrayList}
    }
  }
}

TowerOrUnitData:

data class TowerOrUnitData(val towerOrUnitName:String, val activity:String, var activityData:ArrayList<ActivityData>)

1 个答案:

答案 0 :(得分:2)

更改

TowerOrUnitData{"nil";"nil";activityDataArrayList}

TowerOrUnitData("nil", "nil", activityDataArrayList)

您的 object creating 语法不正确。