I am working on a similar project with a search widget in the action bar. This is only compatible with API 11+, so there are no gingerbread cookies, but it looks better. You still need to tweak the searchable.xml file and add the appropriate metadata to the manifest. I'm not sure how you are going to implement this, but the code below loads a ListView and then adds a row. The onCreateOptionsMenu () section customizes the search widget and filters the ListView based on the imputed text. Hope this helps!
public class ListOfMathCourses extends ListActivity { ArrayAdapter<String> adapter; ListView list; String[] math = new String[] {"Pre-Algebra", "Algebra I", "Algebra II", "Geometry", "Calculus"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.startingpoint); list = (ListView) findViewById(android.R.id.list); adapter = new ArrayAdapter<String>(this, R.layout.listviewrow, math); list.setAdapter(adapter); getListView().setTextFilterEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search, menu);
}
source share