OnItemClick不工作,如果有滚动型的布局 [英] OnItemClick doesnt work if there is ScrollView on layout

查看:178
本文介绍了OnItemClick不工作,如果有滚动型的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView,这里是它的行布局

I have a ListView and here is its row layout

<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>

我在我的布局来实现滚动型,说明<一个href=\"http://stackoverflow.com/questions/21778531/center-image-horizontal-in-imageview-without-centering-it-vertically\">here.

所以,我的问题是OnItemClickListener,我设置的ListView不工作。我可以实现OnTouchListener,但在情况下,我需要知道点击项目的位置和ID。

So, my trouble is OnItemClickListener that I set to listView doesnt work. I could implement OnTouchListener, but in the case I need to know position and id of the clicked item.

UPD1:我的ListView code。

UPD1: code of my listView. Here it is

 <ListView 
    android:id="@+id/exploreList"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

UPD2:我不需要滚动滚动型本,只有ListView控件。此外,我想OnItemClickListener工作。

UPD2: I dont need to scroll this ScrollView, only ListView. Also I want OnItemClickListener work.

任何想法?
谢谢你。

Any ideas? Thanks.

推荐答案

好吧,我研究的意见和aswers,并试图实现其他的解决方案。在这里,我发现了什么。

Well, I have researched comments and aswers and tried to implement other solution. And here what I found.

要求是 - 到图像视图的顶部和侧面绑定在底部裁剪它。但是,这种观点是实现像在ListView项,所以我要保存所有的重点和听众在ListView。

The requirement was - to bind the image to the top and sides of View with cropping it in the bottom. But this View is implemented like item in the ListView, so I have to save all the focuses and listeners in the ListView.

原因的滚动型破坏的重点和听众,它不能执行。

Cause the ScrollView destroys the focuses and listeners, it cant be implemented.

裁剪图像programmaticaly需要花费大量的时间在大画面的情况下。它也不能执行。

Cropping the image programmaticaly takes a lot of time in the case of big pictures. It also cant be implemented.

我决定做它覆盖onMeasure方法在ImageView的,喜欢它在话题的描述方式。

The way I decided to do it is overriding the onMeasure method in the ImageView, like it's described in the topic.

我希望这将有助于给任何人。

I hope it will help to anyone.

这篇关于OnItemClick不工作,如果有滚动型的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆