recyclerview adapter in android code example

Example 1: androidx recyclerview dependency

dependencies {
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    // For control over item selection of both touch and mouse driven selection
    implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01"
}

Example 2: recyclerview adapter in kotlin

class CustomAdapter(private val dataSet: Array<String>) :
        RecyclerView.Adapter<CustomAdapter.ViewHolder>() {

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        
    }

    override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder {
      
    }


    override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {

      
    }

    override fun getItemCount() {
    }

}

Example 3: RECYCLER VIEW

Elective Subjects Notes