3

I have a listview. And a row layout containing few layouts in it. Inside the row layout I have a TextView on which I want to enable autolink When I am enabling the autolink, the link is working fine but the feedback which we get when we click a list row is not working anymore.

When within the row layout, I click anywhere outside the Textview, it gives the feedback, but when I am clicking on the TextView it is not giving the feedback.

So I am guessing that the autolink for the textview is stealing the ontouchevent, and thus it is not reaching to the list view feedback functionality.

This is the xml code for the list row view.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" 
android:focusable="false"
android:background="@color/Green">

<TextView
    android:id="@+id/delivery_date"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_margin="5dp"
    android:background="@color/Blue"
    android:padding="5dp"
    android:text="Delivery date"
    android:textAlignment="center"
    android:textAppearance="?android:attr/textAppearanceSmall" />


<android.support.v7.widget.CardView
        xmlns:cardview="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:background="@color/White"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        cardview:cardCornerRadius="5dp"
        cardview:cardElevation="5dp"
        cardview:cardBackgroundColor="@color/White"
        cardview:cardUseCompatPadding="true"
        >
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:descendantFocusability="blocksDescendants">
<TextView
    android:id="@+id/message_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:paddingTop="10dp"
    android:layout_marginBottom="10dp"
    android:text="M"
    android:gravity="top"
    android:textAppearance="?android:attr/textAppearanceMedium" 
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:autoLink="web"
    android:background="@color/Blue"
    />

    <ImageButton
      android:id="@+id/Share"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/message_text"
      android:focusable="true"
      android:layout_margin="5dp"
      android:background="@drawable/share3"
    android:adjustViewBounds="True" />

 <TextView
     android:id="@+id/time"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignBaseline="@+id/Share"
      android:layout_alignBottom="@+id/Share"
      android:layout_alignParentRight="true"
     android:layout_margin="5dp"
     android:text="Timexxxxx"
     android:layout_gravity="right"
     android:textAppearance="?android:attr/textAppearanceSmall"
     android:textColor="@color/Time" />

 <ImageView
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_above="@+id/time"
     android:layout_alignParentLeft="true"
     android:paddingBottom="2dp"
     android:paddingLeft="5dp"
     android:paddingRight="5dp"
     android:paddingTop="2dp"
     android:layout_marginTop="10dp"
     android:scaleType="fitXY"
     android:src="@android:drawable/divider_horizontal_bright" />

 </RelativeLayout>
 </android.support.v7.widget.CardView>

</LinearLayout>

CAn anyone please help here? Also if anyone can explain any rules related to how the events are passed from children to parent, and relevance of properties like android:focusable and android:descendantFocusability ?

Thanks a ton in advance!

Amar
  • 420
  • 3
  • 14

0 Answers0