Reputation: 65
I have a list view and I am trying to catch the OnItemClickListener event. I guess I somehow prevent it with my row properties. Before asking this question I took a look at the forum and other questions, and tried using the solutions. It only partly helped.
Right now the I catch the event only while pressing on the side (not on any component on the layout only in the blank space, in the left side)
My listView item xml file is:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="340dp"
android:descendantFocusability="blocksDescendants"
android:layout_height="160dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="40dp"
android:layout_height="90dp"
android:background="@drawable/triangle"
android:id="@+id/relativeLayout"/>
<LinearLayout android:id="@+id/desclayout"
android:layout_marginLeft="40dp"
android:layout_width="240dp"
android:layout_height="140dp"
android:background="@drawable/layout_my_posts_selector"
android:layout_marginRight="5dp">
<TextView
android:id="@+id/myPostDescription"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left"
android:maxLength="120"
android:hint="@string/description"
android:inputType="textMultiLine"
android:lines="4"
android:maxLines="5"
android:paddingBottom="8dp"
android:textColorHint="#f7941e"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="8dp"
android:textColor="#6d6e71"
android:scrollbars="vertical"
android:textSize="14sp">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_toRightOf="@+id/desclayout"
android:background="@drawable/description_layout_my_posts_selector"
android:orientation="vertical"
android:paddingLeft="7dp"
android:layout_height="140dp">
<ImageButton
android:id="@+id/acceptMyPostBtn"
android:layout_width="40dp"
android:background="@drawable/my_posts_button_selector"
android:layout_marginTop="5dp"
android:layout_height="40dp"
android:src="@drawable/v"/>
<ImageButton
android:id="@+id/closeMyPostBtn"
android:layout_width="40dp"
android:background="@drawable/my_posts_button_selector"
android:layout_below="@id/acceptMyPostBtn"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:src="@drawable/x"/>
<ImageButton
android:id="@+id/showOnMapMyPost"
android:layout_width="40dp"
android:src="@drawable/location"
android:background="@drawable/my_posts_button_selector"
android:layout_marginTop="5dp"
android:layout_height="40dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_below="@+id/desclayout"
android:paddingLeft="6dp"
android:background="#2d2d2d"
android:layout_height="20dp">
<TextView
android:layout_width="fill_parent"
android:layout_marginLeft="40dp"
android:textColor="@android:color/background_light"
android:text="Finished at 19/01/2013 13:55"
android:layout_height="fill_parent" />
</LinearLayout>
</RelativeLayout>
And the list view definition is:
<ListView
android:id="@+id/my_Posts_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@drawable/my_posts_selector"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp" />
I have tried adding the setFocusable:false to all the components and it still didn't work.
If you can guide me I will be thankful,
Thanks in advance!
Upvotes: 0
Views: 55
Reputation: 3054
Default clickable of ImageButton
is true. So you'll need set android:clickable="false"
to each of your ImageButton
.
Upvotes: 0
Reputation: 5096
Try to add:
android:clickable="false"
To every View in the List Item.
Upvotes: 1