Created
November 24, 2022 08:38
-
-
Save ibrahim-mrq/9b6af89ce92f1f796169004a4e288340 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end | |
| import android.content.Context | |
| import android.view.LayoutInflater | |
| import android.view.ViewGroup | |
| import androidx.recyclerview.widget.RecyclerView | |
| class ${NAME}Adapter(val context: Context) : RecyclerView.Adapter<${NAME}Adapter.${NAME}ViewHolder>() { | |
| var list = emptyList<${Model_Name}>() | |
| class ${NAME}ViewHolder (val binding: Custom${NAME}Binding) : RecyclerView.ViewHolder(binding.root) | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ${NAME}ViewHolder { | |
| return ${NAME}ViewHolder( | |
| Custom${NAME}Binding.inflate( | |
| LayoutInflater.from(parent.context), | |
| parent, | |
| false | |
| ) | |
| ) | |
| } | |
| override fun onBindViewHolder(holder: ${NAME}ViewHolder, position: Int) { | |
| val model = list[position] | |
| } | |
| override fun getItemCount(): Int { | |
| return list.size | |
| } | |
| fun setData(newList: List<Person>) { | |
| list = newList | |
| notifyDataSetChanged() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment