0

I've an action bar and three tabs each includes some list to display. When I click search I want the rest of the action bar should be hidden except the list in a tab and search item it self should be enabled, where want to search.

How can I achieve it?

Edit:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- Single menu item 
     Set id, icon and Title for each menu item
-->

<item
    android:id="@+id/action_search"
    android:title="@string/action_search"
    android:orderInCategory="100"
    android:icon="@drawable/ic_action_search"
    app:showAsAction="ifRoom|collapseActionView"
    app:actionViewClass="android.support.v7.widget.SearchView"/>

<item android:id="@+id/home"
    android:icon="@drawable/icon_home"
    android:title="Home" />

<item android:id="@+id/totalCash"
    android:icon="@drawable/icon_delivered"
    android:title="Cod" />

<item android:id="@+id/statusForEach"
    android:icon="@drawable/icon_cancelled"
    android:title="Status" />

<item android:id="@+id/logout4"
    android:icon="@drawable/icon_cancelled"
    android:title="Logout" />

<!--<item android:id="@+id/menu_delete"
    android:icon="@drawable/icon_delete"
    android:title="Delete" />

<item android:id="@+id/menu_preferences"
    android:icon="@drawable/icon_preferences"
    android:title="Preferences" />-->

Kishore Kumar Korada
  • 1,204
  • 6
  • 22
  • 47

2 Answers2

0

add below line to all menu items except search

    app:showAsAction="ifRoom"

and in your search item add

    app:iconifiedByDefault="true"
Ragesh Ramesh
  • 3,470
  • 2
  • 14
  • 20
0

You have to implement MenuItemCompat interface to get those events. that will allow you to listen open and close and many more events. so check it.

Wasim K. Memon
  • 5,979
  • 4
  • 40
  • 55
  • I used the same. But here I'm having events on search like onQueryTextSubmit or onQueryTextChange. But question is on click on search I want to hide entire action bar except search and list. Just like whatsapp. – Kishore Kumar Korada Feb 17 '16 at 05:29