You need to use ActionBarSherlock. To do this, you need to expand your activities and the ActionBarSherlock component. Something else like this:
MySearchActivity extends SherlockActivity {}
or if you want to use the assembly API in the list of APIs, you can simply do this:
MySearchActivity extends SherlockListActivity {}
then in the res / menu folder create an activity_mysearch.xml file with something like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_search" android:icon="@drawable/ic_menu_search" android:title="@string/menu_search" android:showAsAction="ifRoom|collapseActionView" android:actionViewClass="com.actionbarsherlock.widget.SearchView" </menu>
Now your activity implements OnQueryTextListener. In onCreateOptionsMenu, do:
inflater.inflate(R.menu.activity_mysearch, menu); MenuItem searchViewMenuItem = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) searchViewMenuItem.getActionView(); searchView.setOnQueryTextListener(this);
Now you can use
onQueryTextSubmit(String query) onQueryTextChange(String newText)
to request your list and update the list item. You can also add a filter to the adapter and create an interface that notifies the action of canceling list views after changing the adapter dataset.
source share