Skip to content Skip to sidebar Skip to footer

Onclick Never Called In A Fragment, Android

I'm working on an android project using dynamically created fragments, and I struggle to catch the users events... here-s the incriminate code. public View onCreateView(LayoutI

Solution 1:

To make layout click-able need to set click-able property ofelementlayout :

elementlayout.setClickable(true);

Also set

android:duplicateParentState="true"

in R.layout.relative for all child Views.

Solution 2:

You can replace one fragment with the other via an activity. Have a look at this link. This is the most modular approach to go from one fragment to another.

Solution 3:

Ok, I finally found the problem after some days.

It seems that the ScrollView was stealing the focus, making the layout inside and outside unable to receive the user's click.

Removing it fix the problem (which was not linked to the fragment, in the end...).

Post a Comment for "Onclick Never Called In A Fragment, Android"