【发布时间】:2014-02-14 15:42:56
【问题描述】:
我有一个 ListView,这是它的行布局
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="280dp">
<ScrollView
android:scrollbars="none"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/exploreImage"
android:src="@drawable/beard1"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</ScrollView>
<TextView
android:id="@+id/exploreText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
我必须在我的布局中实现 ScrollView,描述是 here。
所以,我的问题是我设置为 listView 的 OnItemClickListener 不起作用。我可以实现 OnTouchListener,但在这种情况下,我需要知道被点击项目的位置和 id。
UPD1:我的 listView 的代码。 这里是
<ListView
android:id="@+id/exploreList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
UPD2:我不需要滚动这个 ScrollView,只需要滚动 ListView。我也想要 OnItemClickListener 工作。
有什么想法吗? 谢谢。
【问题讨论】:
-
您的列表视图在哪里?我没有看到列表视图!
-
@WarrenFaith 我展示了我的行布局代码,我的 ListView 代码会有帮助吗?哦
-
假设你想检测列表中被点击的项目为什么不使用 onListItemClick ?如果您不想检测被点击的列表项,那么我不明白您的问题。
-
好的,您希望滚动容器(您所在行中的 ListView 和 ScrollView)如何确定您想要滚动的内容?恕我直言,您的设计有缺陷!
-
@pedromss 确切地说,我想检测点击了哪个项目。我写道,OnItemClickListener 在我的行布局中不起作用,原因是 ScrollView。
标签: android android-listview onitemclicklistener