At the moment I have something like that:
<LinearLayout android:layout_height="80dip" android:id="@+id/linearLayoutSettings"
android:layout_width="80dip" android:orientation="vertical">
<ImageButton android:layout_height="wrap_content" android:src="@android:drawable/ic_menu_manage"
android:id="@+id/imageButton1" android:layout_width="wrap_content"></ImageButton>
</LinearLayout>
LinearLayout has onClick listener attached to it.
Problem: When a ImageButton is clicked inside the LinearLayout, the event doesn’t get triggered.
I could solve it by attaching the same on click to this button as I attached to LinearLayout. But in that case it would mean a lot of repetetive code (have many buttons).
Question: Is there a more effective way to solve this problem?
Attach the following tag to each imagebutton:
android:onClick="yourOnClickFunction"Then, in your activity, add a corresponding function:
In the switch-block you need to know about the buttons IDs. You can get them via findViewById(R.id.aButton).