0

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" />
GAMA
  • 5,958
  • 14
  • 79
  • 126
marceloamx
  • 108
  • 2
  • 12

1 Answers1

1

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

vasart
  • 6,692
  • 38
  • 39
  • when I make the gesture in an area that does not overlap the listview, the gesture is properly detected. But the gesture must be made in RelativeLayout that overlaps the listview, and when I click on any area that is overlapped, the listview is always the element detected ... – marceloamx Jun 18 '12 at 10:27
  • Try applying `GestureDetector` to the layout below `ListView` and `RelativeLayout`. For example, you can use `findViewById(android.R.id.content);` – vasart Jun 18 '12 at 11:05