Listview Onitemclicklistener Does Not Work Android
Ive seen plenty of posts, plenty of tutorials but i can't find the key to make this work. I have a listView with friend requests,as u see these requests have 2 buttons (accept or d
Solution 1:
onItemClicked
is not called because of the Button
, in your row. Add
android:descendantFocusability="blocksDescendants"
to the root of your single_request
layout
Solution 2:
In single_request
layout you have focusable
item like Button
thats why onItemClick
is not fired. set all focusable
items focusability false
.
code snippet for focusable item like button
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
android:text="Button" />
If you want to set onClick
of those Buttons
set it inside your CustomAdapter
.
Solution 3:
I have sane issue happen Instead of button try to use ImageView.
now your single_request_layout will like.
<LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="5dp"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/boxSF1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="2dp"android:orientation="horizontal" ><ImageViewandroid:id="@+id/imageUser"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/perfildefecto" /><RelativeLayoutandroid:id="@+id/boxSF2"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="2dp"android:orientation="vertical"android:padding="5dp" ><TextViewandroid:id="@+id/textViewAmigoUsuario"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="bottom"android:paddingBottom="2dip"android:paddingLeft="5dp"android:paddingTop="6dip"android:textColor="#333"android:textSize="16sp"android:textStyle="bold" /><ImageViewandroid:id="@+id/btnEliminar"android:layout_width="20dp"android:layout_height="20dp"android:layout_alignParentRight="true"android:layout_below="@+id/textViewSolicitud"android:layout_marginTop="30dp"android:background="@drawable/denegar"android:max="100" /><ImageViewandroid:id="@+id/btnAgregar"android:layout_width="20dp"android:layout_height="20dp"android:layout_alignBaseline="@+id/btnEliminar"android:layout_alignBottom="@+id/btnEliminar"android:layout_marginRight="24dp"android:layout_toLeftOf="@+id/btnEliminar"android:background="@drawable/aceptar"android:max="100" /><TextViewandroid:id="@+id/textViewSolicitud"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_centerVertical="true"android:layout_below="@id/textViewAmigoUsuario"android:layout_margin="10dp"android:gravity="left"android:text="@string/friend_request"android:textColor="@color/AzulClaro" /></RelativeLayout></LinearLayout></LinearLayout>
I hope this will work.
Post a Comment for "Listview Onitemclicklistener Does Not Work Android"