Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created February 2, 2018 13:13
Show Gist options
  • Save t-kashima/efa3831aa35daa589745ec5f50975965 to your computer and use it in GitHub Desktop.
Save t-kashima/efa3831aa35daa589745ec5f50975965 to your computer and use it in GitHub Desktop.
package com.unuuu.bookkeeper.view.adapter
...
class ExampleAdapter(context: Context) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
...
private val inflater: LayoutInflater = LayoutInflater.from(context)
private class CommentViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun initialize(comment: Comment) {
comment.subComment.forEach {
// viewをLayoutInflatorを使ってxmlから生成する
val subView = inflater.inflate(R.layout.adapter_example_row_sub_comment, viewGroup, false)
subView.initialize(it)
view.comemntLayout.addView(subView)
}
...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment