Hamid
Hamid

Reputation: 4430

Android, Layout clicklistener and subview click through problem

I have a RelativeLayout to which I add buttons and set their onCLickListener to the current Activity where I handle their clicks.

Under a particular circumstance I need to set the RelativeLayout onClickListener also, but then once finished with the required clicking on the layout, I need to allow clicking on the buttons again. (i.e. clicking throug hthe layout)

If I set the layout's click listener to null I can no longer click either the layout or the buttons that are it's child views.

What am I doing wrong?

EDIT: I seem to have fixed it by setting;

relativeLayout.setClickable(false);

Upvotes: 3

Views: 6831

Answers (1)

pawelzieba
pawelzieba

Reputation: 16082

Have you tried:

relativeLayout.setOnClickListener(null);
relativeLayout.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);

?

Upvotes: 2

Related Questions