嗨,我想知道何时单击我的底部导航查看如何显示我的搜索工具栏?
getMenuInflater().inflate(R.menu.toolbar_menu, menu);
return super.onCreateOptionsMenu(menu);
}
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
return true;
case R.id.navigation_loope:
toolbar_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:title="Search"
android:id="@+id/action_search"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView"/>
</menu>
Bottom_nav_view.xml
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home"
android:title="@string/title_home" />
<item
android:id="@+id/navigation_loope"
android:icon="@drawable/ic_loope"
android:title="@string/title_loope"
/>
<item
android:id="@+id/navigation_take_photo"
android:icon="@drawable/ic_take_photo"
android:title="@string/title_take_photo" />
<item
android:id="@+id/navigation_public"
android:icon="@drawable/ic_public"
android:title="@string/title_public" />
</menu>
当我单击循环(R.id.navigation_loope)时,我实际上不能使用getMenuInflater().inflate(R.menu.toolbar_menu, menu)
我不知道如何实现相同的结果
编辑:Bottom_nav_view是我的底部栏,而toolbar_menu是我的顶部栏。如果单击项目navigation_loop,则希望在顶部显示搜索栏。