Code example for SearchView

Methods: setIconifiedByDefaultsetOnQueryTextListener

0
 
	@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
	private void setupSearchView(MenuItem searchItem) {
 
		if (isAlwaysExpanded()) { 
			searchView.setIconifiedByDefault(false);
		} else { 
			searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM
					| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
		} 
 
		searchView.setOnQueryTextListener(this);
	} 
 
	public boolean onQueryTextChange(String newText) {
		//searchValue.setText("Query = " + newText); 
		return false; 
	} 
 
	public boolean onQueryTextSubmit(String query) {
		//myAddress.setText("Query = " + query + " : submitted");