0
時,onclick未檢測到,我當前爲relative layout
顯示在listview
中。原來,當我點擊RelativeLayout
時,總是被list view
中的點擊事件發現。ListView上的RelativeLayout,當RealtiveLayout顯示爲
我想在顯示佈局時檢測手勢,但是當我點擊時,從下面的listview
中選擇該項目。
任何人都知道這個問題的解決方案?
<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>
ListView控件作爲被插入到:
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="0dp" />
mDetector.setIsLongpressEnabled(true);
第一,並設置視圖可長按,當我做出一個手勢不重疊列表視圖的區域,手勢被正確檢測。但手勢必須在與ListView重疊的RelativeLayout中進行,而當我單擊任何重疊的區域時,列表視圖始終是檢測到的元素... – marceloamx嘗試將'GestureDetector'應用於'ListView'和'RelativeLayout '。例如,你可以使用'findViewById(android.R.id.content);' – vasart