The View Object is from onListItemClick(ListView listView, View view, int position, long id)
is RelativeLayout
.
However, I want to know which component inside the RelativeLayout
is clicked as well for extended functionality.
How do I do that?
The View Object is from onListItemClick(ListView listView, View view, int position, long id)
is RelativeLayout
.
However, I want to know which component inside the RelativeLayout
is clicked as well for extended functionality.
How do I do that?
This answer show why use recyclerview instead of Listview, I think recyclerview will solve your problem stackoverflow.com/a/24933117/2242903
You have to add a listener to every view in RelativeLayout
you want to listen. If you want to use a single listener, create one and add it to all of the views you want to listen. In your onClick
method, you can put view.getId()
to switch statement and determine which one is clicked.
OnItemClickListener
won't solve your problem. Neither switching to RecyclerView
. They work the same way. It is all about your adapter. If you are using a custom adapter, it doesn't matter you use ListView
or RecyclerView
. In your adapter, you have access to your components that are in your RelativeLayout
. Create a listener as I explained above and add them to your views.
Not the same but similar question: Android: Add event listeners to every item in a ListView