Only text from ListView items is clickable

We have a ListView with dynamic content, and we can only click on the text, not the whole element (this means that short text means a small touch area)

Our ListView:

 ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(this); 

What do we need to do to make the whole element clickable, and not just its text

+4
source share
3 answers

Be sure to fill in all the lists of the list with the text field that you use, put it in your propositions:

 android:layout_width="match_parent" 
+3
source

You will need to capture the touch event in the parent textview element. see onInterceptTouchEvent

0
source

Set the width of the listView layout to fit it:

 android:layout_width="match_parent" 

Otherwise, although the line looks like the full width of the screen, in fact there is no list.

0
source

Source: https://habr.com/ru/post/1345841/


All Articles