Created
April 19, 2018 02:34
-
-
Save xloger/c53939f3017967da99f5b32446bee036 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleAdapter<T>(val list: List<T>, val layoutResource: Int, val bind: (holder: ViewHolder, t : T) -> Unit) : RecyclerView.Adapter<SimpleAdapter.ViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
return ViewHolder(LayoutInflater.from(parent.context).inflate(layoutResource, parent, false)) | |
} | |
override fun getItemCount(): Int = list.size | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
bind(holder, list[position]) | |
} | |
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment