I have a ViewGroup (LinearLayout) which contains a couple of TextViews and one ImageView. I want to make this entire group clickable.
I tried something like this:
viewGroup.setOnClickListener( new OnClickListener(){
@Override
public void onClick() {
开发者_JAVA百科 //do stuff
}
});
However, clicks on the TextViews or ImageViews or on the area enclosed by the ViewGroup above doesn't result in the handler being called.
Any suggestions on how I can make a whole ViewGroup clickable?
Solution was as simple as adding
android:clickable="true"
to the xml for the RelativeLayout
group
Make the layout click-able. You can make the layout clickable (you might have to use the focus attributes). Just don't forget to assign an ID to the layout so you can detect it.
精彩评论