android - 如何为列表视图下的视图设置点击监听器
问题描述
我有一个它的listview
is ,在它的标题下有一个视图,我想在项目通过滚动之前点击它。header
header
transparent
listview
我搜索了一些解决方案,例如:使用cancelable
或focusable
标题的属性并将这些值设置为 false;但问题仍然存在!
在这种特殊情况下,如何访问另一个视图下的视图的 onclick 监听器?
我想点击orderTypeLinearLayout
<RelativeLayout 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"
android:background="@color/lightestGray"
android:orientation="vertical">
<LinearLayout
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:orientation="vertical">
<LinearLayout
android:id="@+id/headerLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:background="@color/gray"
android:orientation="vertical"
android:padding="10dp">
<ImageView
android:id="@+id/titleImageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scaleType="centerInside"
tools:ignore="ContentDescription,NestedWeights" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/orderTypeLinearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_arrow_drop_down_white"
tools:ignore="ContentDescription,RtlHardcoded" />
<TextView
android:id="@+id/orderTypeTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="left"
android:textColor="@color/white"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<TextView
android:id="@+id/userListTitleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="right"
android:textColor="@color/white"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:background="@color/gray" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/scoreBoardSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:id="@+id/scoreBoardFragmentListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="1"
android:divider="@null" />
</android.support.v4.widget.SwipeRefreshLayout>
解决方案
推荐阅读
- javascript - 为什么我的模块函数的 Jest 间谍在另一个模块中使用,在测试后一个模块的函数时没有被调用?
- python - 如何在 postgreSQL 中构建表
- java - 如何在场景构建器中添加我的自定义布局管理器?
- visual-c++ - rust 编译时 1 字节的结构成员对齐 (rustflags)
- javascript - 使用 For 循环在数组中递归搜索
- mysql - 如何在父查询案例语句中使用子查询的结果
- java - Thymeleaf 无法识别服务的属性
- xml - XPath 谓词仅使用节点集中的第一个节点进行匹配
- javascript - React Native:尝试通过道具传递参考函数
- matplotlib - matplotlib 图形屏幕菜单改变了吗?