To group the icon and text, I grouped them in linear mode and implemented a listener for the linear layout.
<LinearLayout
android:id="@+id/ll0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imageButton0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/start" />
<TextView
android:id="@+id/textView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
I implemented the listener as follows: -
l0 = (LinearLayout)findViewById(R.id.ll0);
l0.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
}
});
The problem I am facing is that I click on the icon, the listener does not seem to respond. The listener worked when I press the space bar between the text image and the icon. I would like the whole part to be clickable, and not at any particular point.
source
share