Trying to get an onclick listener that works on linearlayout but never called it :(. Enabled clickable and focsuable (both modes) and still can't get a click responder. Platform details: Android 3.0 .. Any help? Code below
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu_items_button" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" android:gravity="center_horizontal" android:paddingTop="@dimen/gen_margin_xsmall" android:paddingBottom="@dimen/gen_margin_xsmall" android:background="@drawable/rule_bg_menu_button" android:clickable="true" android:focusableInTouchMode="true" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/menu_items" android:tag="image" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:tag="text" android:text="@string/menu_items_icon_txt" style="@style/textDisplay.mediumLarge" /> </LinearLayout>
and in the code to add an event listener
_itemsButton = (LinearLayout) menu.findViewById(R.id.menu_items_button); final Intent itemsIntent = new Intent(this, ItemsActivity.class); _itemsButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { startActivity(itemsIntent);
The reason why I do this, and not use the "Image" button, is because the background of the "button" is based on the state (gradient change), as well as the image and in order to combine with them by clicking / on focus, I used linearlayout, which has an ImageView on its own .. any suggestions on why clickListener is not working on linearLayout?
THX
source share