I have one activity from where i am loading 6 fragments. Six of three fragments have the searchview and rest of the three have not implemented the searchview.
I have made two menu.xml in which
- one having the searchview and commonitem for action bar and other
- one does not have the searchview and contains common items
Now if i expand the searchview in the first tab and then move to the second tab,searchview still get opened(i know it is the searchview of the second tab as i have implemented the onCreateOptionMenu() for the each fragments),which i don't want.
What i want is when i move to the first fragment to second or third at that time searchview should get collapsed and only click of the searchview(in current fragment it should get expanded).
Moreover, if i move to the first fragment to 2nd,3rd and 4th(my account info fragment,not contain searchview in action bar),then in 4th fragment i still get the searchview in open mode...
Another thing that i want to know,by clicking on the searchview it gets expanded and also popup the soft keyboard,so is this is the default behavior of the searchview (expanding and open keyboard)?
I want to open keyboard when i click on the text(edit text) area of the searchview.
Hope m clear.... Any Suggestion/Links will be appreciated...
Let me know if any more detail you required from my side.....
EDIT ::
Applying S.D.'s solution
Testing on 2.3.6
1)When i am on the first fragment(First Tab)
2)After Expanding it in same fragment ::
3)Move to the next Fragment(Tab,by keeping the searchview opened) ::
Testing on the 4.2.1 ::
1)When i am on the first fragment(First Tab)
2)After Expanding it in same fragment ::
3)Move to the next Fragment(Tab,by keeping the searchview opened) ::
i have set 'setIconified(true)' in my Container Activity(from where my all fragment loded) in below methods ::
@Override
public void onPageSelected(int position)
{
if (searchView!=null && !searchView.isIconified()) { //true == searchView closed
searchView.setIconified(true);
searchView.setIconified(true);
}
actionBar.setSelectedNavigationItem(position);
}
@Override
public void onTabSelected(Tab tabposition, FragmentTransaction fragmentposition) {
if (searchView!=null && !searchView.isIconified()) { //true == searchView closed
searchView.setIconified(true);
//searchView.setIconified(true);
}
awesomePager.setCurrentItem(tabposition.getPosition());
}