Skip to content

Instantly share code, notes, and snippets.

@hirauchg
Last active May 19, 2019 15:28
Show Gist options
  • Save hirauchg/6295f2ba9f5c5fb33e9b5513143bcfb5 to your computer and use it in GitHub Desktop.
Save hirauchg/6295f2ba9f5c5fb33e9b5513143bcfb5 to your computer and use it in GitHub Desktop.
RecyclerViewでリスト表示を実装する - リスト表示画面の実装 - 1
class SampleActivity : BaseActivity(), SampleAdapter.SampleAdapterListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val ui = SampleActivityUI()
ui.setContentView(this)
// テストデータ
val sampleModelList = arrayListOf<SampleModel>()
for (i in 0..20) {
val sampleModel = SampleModel(i, "SampleModel" + i)
sampleModelList.add(sampleModel)
}
val adapter = SampleAdapter(this)
adapter.setSampleModelList(sampleModelList)
ui.mRecyclerView.adapter = adapter
}
override fun onClickCard(position: Int) {
toast("onClickCard : " + position)
}
override fun onClickDelete(position: Int) {
toast("onClickDelete : " + position)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment