user4272989
user4272989

Reputation:

Android actionbar search in a tabview

I am working with android fragments.I have a main activity and 3 fragments (tab1,tab2,tab3) in my app.Each fragment contains its own custom listview using base adapter.I want implement action bar search view in each fragment.I can do it using edittext search actions using setting editttext in each layout. But my question is is it possible to do it with actionbar searchview in each tab ?? If yes how can I detect which tab is currently selected or focused ?? and is it possible to do it with custom listview in fragment?? Please help me with some links or answer. Thanks in advance :)

Upvotes: 1

Views: 849

Answers (1)

Goran Horia Mihail
Goran Horia Mihail

Reputation: 3645

Yes, the answer for all your questions its "yes".

You can use only one search box to filter all the listviews in all tabs / fragments. (I assume this is what you are trying to do)

TabHost has a method getCurrentTab() which returns the index of the tab that's in focus.

The content of the search bar (which is an EditText) you know now to which fragment to send. You can use this to filter the ListView.

Upvotes: 1

Related Questions