I have method called getEventId in the DataAdapter class but I'm unable to access it from my MainActivity class and not sure why?
DataAdapter
class DataAdapter (events: ArrayList<Array<String>>) : RecyclerView.Adapter<DataAdapter.ViewHolder>() {
private val TAG = "Adapter"
private val events = events
inner class ViewHolder (view: View) : RecyclerView.ViewHolder(view) {
var id = ""
val title: TextView = view.txtTitle
val date: TextView = view.txtDate
}
fun getEventId (position: Int): Int? {
return if (events.isNotEmpty()) events[position][0].toInt() else null
}
.....
}
MainActivity
class MainActivity : AppCompatActivity(), RecyclerItemClickListener.OnRecyclerClickListener {
private val eventsDatabase: DatabaseHelper = DatabaseHelper(this)
private var events = ArrayList<Array<String>>()
...
override fun onItemClick(view: View, position: Int) {
var itemId = DataAdapter.getEventId(position)
Toast.makeText(this, "Normal tap on id: $itemId", Toast.LENGTH_SHORT).show()
}
...
}