RecyclerviewTableViewAndroid icon indicating copy to clipboard operation
RecyclerviewTableViewAndroid copied to clipboard

Add row click listener functionality to TableView for user interaction

Open Copilot opened this issue 6 months ago • 1 comments

This PR implements row click listener functionality for the RecyclerView TableView, enabling users to interact with table rows for editing or other actions as requested in the issue.

Changes Made

1. Added OnRowClickListener Interface

Created a clean callback interface that provides both the clicked movie data and its position:

interface OnRowClickListener {
    fun onRowClick(movie: MovieModel, position: Int)
}

2. Enhanced TableViewAdapter

  • Added setOnRowClickListener() method to register click callbacks
  • Implemented selective click handling - only content rows are clickable
  • Header row is explicitly protected from clicks to prevent confusion
  • Click listener provides complete movie data and position for easy integration
// Content rows get click listeners
itemView.setOnClickListener {
    onRowClickListener?.onRowClick(modal, rowPos - 1)
}

// Header row is protected
itemView.setOnClickListener(null)
itemView.isClickable = false

3. Updated MainActivity

  • Implements the OnRowClickListener interface
  • Demonstrates functionality with detailed Toast messages showing clicked row information
  • Includes TODO comments for easy integration with edit activities

Usage Example

val adapter = TableViewAdapter(movieList)
adapter.setOnRowClickListener { movie, position ->
    // Start edit activity
    startActivity(Intent(this, EditMovieActivity::class.java).apply {
        putExtra("movie_data", movie)
        putExtra("position", position)
    })
}

Key Features

  • Minimal impact: Only 39 lines added across 2 files, no breaking changes
  • Selective interaction: Header row protected, only data rows are clickable
  • Complete data access: Callback provides both movie object and list position
  • Integration ready: Designed for seamless connection to edit activities
  • Optional functionality: TableView works normally with or without click listener

The implementation follows Android best practices and maintains the existing table structure while adding the requested user interaction capability.

Fixes #5.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Aug 07 '25 12:08 Copilot

@monsterbrain 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot avatar Aug 07 '25 12:08 Copilot