1

I use an Adapter with a ListView...

I want to trigger the ListView click and disable item clicks (visually)

In my Adapter I do something like to disable visual click feedback:

@Override
public View getView(int pos, View convertView, ViewGroup parent)
{
    if (convertView == null)
        convertView = LayoutInflater.from(mParent).inflate(R.layout.row_set, null);

    convertView.setClickable(false);
    convertView.setFocusable(false);
    convertView.setFocusableInTouchMode(false);

    ...

    return convertView;
}

but that does not work either.

Setting an OnClickListener on a ListView isn't allowed as well, so I don't know how to trigger a click on the ListView

I would like to have unclickable items and a clickable listview...

prom85
  • 16,896
  • 17
  • 122
  • 242
  • set listener for convertView – Raghunandan Jan 21 '14 at 14:41
  • what about this one convertview.setonclicklistener()? – UMAR-MOBITSOLUTIONS Jan 21 '14 at 14:43
  • The convertView is the ROW/ITEM! I want, that this is NOT clickable, but the ListView as a whole should have a click listener... I need something like a context menu for the listview, not for the items – prom85 Jan 21 '14 at 14:44
  • 1
    use onTouch, when you touch, on action down, on action up, activate your method – Tsunaze Jan 21 '14 at 14:54
  • Have you tried wrapping your `ListView` in its own `ViewGroup` and making that clickable? – codeMagic Jan 21 '14 at 14:54
  • what do you mean? wrapping the `ListView` in a `LinearLayout` for example? I tried that, I even made my `ListView` not clickable and not focusable, but the View behind won't get the click delegated... – prom85 Jan 21 '14 at 15:13
  • Yes, a `LinearLayout`, for example. Then make the rows not clickable and if you have `Button`s or any other `View`s that would be clickable by default then set their clickable property to false. – codeMagic Jan 21 '14 at 15:21
  • I tried making all items not clickable and/or the listview not clickable, but that did not work.. btw, my rows don't have clickable items, so this is no problem – prom85 Jan 21 '14 at 15:23
  • I see you have a solution but just for clarity, I meant to make everything not clickable, except the `ListView` and make the parent `View`, such as a `LinearLayout`, clickable and set an `OnClickListener` to that parent `View`. – codeMagic Jan 21 '14 at 15:26
  • the parent view is clickable and has an click listener... with all items in my listview not clickable and my listview either clickable or not, the parent did not get the click... I tried that, but this way it did not work... – prom85 Jan 21 '14 at 15:30

2 Answers2

1

Try to set your own touchListener,and to handle touch events

Eddy
  • 489
  • 4
  • 10
0

set android:descendantFocusability="blocksDescendants" its row xml file and you can try for list view whatever best suit for you.check all op