I'm trying to make a Toast indicating the selected Item so I used this but when I run the application it shuts down. Do you know the correct way for doing this? Thank you
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentPrimerBinding.bind(view)
val arrayAdapter : ArrayAdapter<*>
val tableros = mutableListOf("3x4","3x7","3x8","3x9","3x10","4x5","4x6","4x7","4x8","4x9","5x5","5x6","5x7","5x8","5x9").toList()
arrayAdapter = context?.let { ArrayAdapter(it.applicationContext,android.R.layout.simple_list_item_1,tableros) }!!
binding.listview.adapter = arrayAdapter
binding.listview.setOnItemClickListener{parent, view, position, id ->
Toast.makeText(requireContext().applicationContext,binding.listview.selectedItem.toString(),Toast.LENGTH_LONG).show()
}
}
Well using the "position" was the solution :) i hope it's helpfull to anyone