java在工具栏支持操作栏中设置搜索不起作用为什么?
我一直在尝试为我的应用添加/创建搜索功能!所以在通过安卓文档之后,就有了如何做到这一点的培训!我添加了它,因为它解释了,但它不工作,当我点击搜索图标,它没有反应,我甚至不能把任何文本进行搜索!我使用的是支持版本25
<安卓.support.design.widget.CoordinatorLayout
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent">
<include layout="@layout/toolbar"/>
<安卓.support.v4.widget.NestedScrollView
安卓:id="@+id/myScrollingContent"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent">
<FrameLayout
安卓:id="@+id/contentContainer"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:layout_above="@+id/bottom_bar" />
</安卓.support.v4.widget.NestedScrollView>
<com.roughike.bottombar.BottomBar
安卓:id="@+id/bottom_bar"
安卓:layout_width="match_parent"
安卓:layout_height="60dp"
安卓:layout_gravity="bottom"
app:bb_tabXmlResource="@xml/bottombar_tabs_three"
app:bb_behavior="shy"/>
</安卓.support.design.widget.CoordinatorLayout>
# 1 楼答案
尝试使用查询侦听器。它检测在searchview中进行的任何输入
# 2 楼答案
经过一番努力,我意识到这个错误是由于在协调器布局中包装视图造成的。所以工具栏的点击并没有被它后面添加的其他视图占据。所以我可以更改布局属性,但我决定改用相对布局