There is a LinearLayout
with a lot of child elements. When a user touches any of those child elements, the same method will be invoked. In order not to implement the same onClickListener
for each element, I implemented the onClickListener
for the parent LinearLayout ONLY.
Now, when I click anywhere within the parent layout's borders, the desired method is being invoked just as I have implemented the listener for all child elements.
Q: Can I rely that anytime I implement onClickListener
for the parent, all of its child elements will react to the click event?
Q: What would happen if any child element has its own onClickListener
? Would there be a collision or clicking on that element would fire its own click event only?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…