Search code examples
androidandroid-layoutandroid-listview

Android- Click goes to a ListView in a clickable RelativeLayout instead of the RL


My app has several RelativeLayouts with a TextView and a ListView in each. I've made the RelativeLayouts clickable (and it works well). The problem is, the ListViews that are embedded in them are also clickable, and whenever the user tries to click the area of the RelativeLayout with the list, the click registers for the list instead.

I've tried setting the ListViews as clickable="false" and focusable="false". I've tried descendantsFocusability="blocksDescendants" on the RelativeLayouts. Those don't work.

What's the solution? This is my first app, am I missing something?


Solution

  • I solved my problem by making the lists' items' onItemClick methods mimic the onClick method of their parent RelativeLayout.

    If the parent RelativeLayout would lead to fragmentA, then each item in its child list also leads to fragmentA.

    This feels a bit half-baked and cheap, but it works for now.