安卓:对的ListView一扔检测复杂的行
-
26-09-2019 - |
题
亲爱的Android黑客,我附上一个gestureListener识别甩到ListView。 ListView中的行由一个LinearView和一些TextViews的。不幸的是,未检测到扫视,当它开始于TextViews之一:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#000000" >
<TextView
android:id="@+id/author"
android:textSize="14sp"
android:textColor="#ffffff"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:id="@+id/date"
android:textSize="11sp"
android:textColor="#eeeeee"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"/>
</LinearLayout>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:textColor="#333333"
android:paddingBottom="5dp"
android:textSize="14sp"
android:layout_weight="2"/>
</LinearLayout>
所以,当我开始在水平的LinearLayout一扔,一切工作正常,但是当我开始它在底部TextView的,没有任何反应。它containts可编辑的文本,如果这可能是问题...至于说,监听器连接到ListView本身。
我会很高兴,如果有人能帮助!
扬奥利弗
解决方案
您可编辑的TextView从true
返回onTouch()
,防止事件从由LinearLayout
越往上视图层次正在处理中。
有什么能够阻止你安装一个定制OnTouchListener
您TextView
重写这和事件传递到您现有的GestureDetector
。
textView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent ev) {
return gestureDetector.onTouchEvent(ev);
}
};
不隶属于 StackOverflow