In my application i am trying to add an searchView
in actionbar. But while clicking on the search icon searchView is expanding to the entire actionbar while clicking the key down it is coming to normalView.
While clicking on the search icon. It is coming like this..
But I want a behavior like this..
options_menu.xml
<item
android:id="@+id/search"
myapp:actionViewClass="android.support.v7.widget.SearchView"
myapp:showAsAction="ifRoom|collapseActionView"
android:icon="@drawable/ic_action_search"
android:title="@string/search_title"/>
onCreateOptions() method
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = menu.findItem(R.id.search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
mSearchView.setBaselineAligned(false);
return super.onCreateOptionsMenu(menu);
}
please help me..Thanks in advance...
I just commented the code like this...Now it is working properly...
case R.id.search:
//onSearchRequested();
return true;