我有一個ListView。每個ListView項目都有HorizontalScrollview和textview。水平滾動視圖中有圖像。我正在使用FrameLayout在水平滾動視圖上顯示文本視圖(在左側)。Listview onClick不與覆蓋工作Framelayout android
我可以做到這一點。但是當我點擊TextView來調用ListView的長單擊監聽器時,圖像視圖的OnClick事件被觸發。
這裏是ListView項目的XML文件。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/linearLayoutListViewItem"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal"
>
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
>
<!-- Adding images here programmatically..-->
</LinearLayout>
</HorizontalScrollView>
<!-- Textview That i want to show on left side Above the images in HorizontalScrollview-->
<gallery.com.activity.CustomTextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#a0000000"
android:gravity="center"
android:padding="7dp"
android:textSize="16dp"
>
</gallery.com.activity.CustomTextView>
</FrameLayout>
此外,這是我的ListView XML文件。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<gallery.com.activity.DynamicListView
android:id="@+id/listView"
android:background="#0000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
/>
</LinearLayout>
那麼,我該如何調用ListView的長點監聽器? 請幫忙。 請讓我知道你是否想要更多澄清問題。
是的..在動態列表中,我正在實施它.. – 2015-02-24 09:29:22
它是否工作? – 2015-02-24 09:29:40
問題是當我使用LinearLayout而不是FrameLayout其工作.. – 2015-02-24 09:30:28