如何在kotlin中的自定义onItemClickListener()
上实施listView
?_
title_list_view.setOnItemClickListener{ adapterView: AdapterView<*>?,
view: View?, position: Int, l: Long ->
}
点击自定义ListView
的项目后,如何开始新活动?
答案 0 :(得分:1)
试试这个
title_list_view.setOnItemClickListener { parent, view, position, id ->
Toast.makeText(this, "Clicked item :"+" "+position,Toast.LENGTH_SHORT).show()
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
intent.putExtra("position", position);
this.startActivity(intent);
}
答案 1 :(得分:0)
你正在使用kotlin吗?
在Intent中使用 NextActivity :: class.java
title_list_view.setOnItemClickListener { parent, view, position, id ->
Toast.makeText(this, "Clicked item : $position",Toast.LENGTH_SHORT).show()
Intent intent = new Intent(CurrentActivity.this, NextActivity::class.java)
intent.putExtra("position", position)
this.startActivity(intent)
}