问题描述:

I am currently a relative layout is shown in a listview. Turns out that when I click RelativeLayout, is always caught the click event in the list view.

I wanted to detect a gesture on the layout when it is being shown, but when I click, the item is selected from the listview that is underneath.

Anyone know a solution to this problem?

<TabHost

android:id="@android:id/tabhost"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_below="@+id/start_tabs_topbar" >

<LinearLayout

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical"

android:padding="0dp" >

<FrameLayout

android:id="@android:id/tabcontent"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:padding="0dp" />

<TabWidget

android:id="@android:id/tabs"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_marginBottom="-4dp"

android:layout_weight="0" />

</LinearLayout>

</TabHost>

<RelativeLayout

android:id="@+id/playertab1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="@drawable/back_artista"

android:gravity="center_vertical|left"

android:paddingLeft="15dp" >

<LinearLayout

android:id="@+id/music_info"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_gravity=""

android:orientation="horizontal" >

<ImageView

android:id="@+id/artist_image"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginRight="9dp"

android:layout_marginTop="4dp"

android:src="@drawable/placeholder" />

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:gravity="top"

android:orientation="vertical" >

<TextView

android:id="@+id/playlist_name"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="playlist_name"

android:textColor="#3BBEF9"

android:textSize="15dp"

android:textStyle="bold" />

<TextView

android:id="@+id/artist_album"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="artist_album"

android:textColor="#EEEEEE"

android:textSize="11dp" />

<TextView

android:id="@+id/artist_name"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="artist_album"

android:textColor="#EEEEEE"

android:textSize="11dp" />

<TextView

android:id="@+id/artist_song"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="artist_song"

android:textColor="#EEEEEE"

android:textSize="11dp" />

</LinearLayout>

</LinearLayout>

</RelativeLayout>


The listview as been inserted into:

 <FrameLayout

android:id="@android:id/tabcontent"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:padding="0dp" />

网友答案:

If you are using GestureDetector try calling mDetector.setIsLongpressEnabled(true); first and set view long clickable via convertView.setLongClickable(true);

相关阅读:
Top