class TodoActivity: AppCompatActivity() {
var id = 0L
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_todo)
setSupportActionBar(toolbar1)
val taskList = ArrayList<Task>()
val task1 = Task(id++, "Task", "Make awesome Tasks", Date())
taskList.add(task1)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.adapter = TaskAdapter(taskList) {
toast("${it.title}Clicked")
}
fab.setOnClickListener {
taskList.add(Task(id++, "Task${id}", "Description for Task ${id}", Date()))
recyclerView.adapter.notifyDataSetChanged()
}
if (taskList.size > 0)
tvNotTask.visibility = View.GONE
else
tvNotTask.visibility = View.VISIBLE
}
private fun toast(msg: String) = Toast.makeText(this, msg, Toast.LENGTH_LONG).show()
}
this is my code, and when I want to run my App I get this following error
Smart cast to 'TaskAdapter' is impossible, because 'recyclerView.adapter' is a complex expression
does anybody know what to do I also can add the Layout file if you need to know something from overthere