Code example for SearchView

Methods: clearFocus, getWindowToken

2
	// remove focus from the search window to hide soft key board from view 
	public static void clearSearchViewFocus(Context context, SearchView view) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			if (view != null) {
				// clear focus 
				view.clearFocus();
				// and hide keyboard 
				InputMethodManager inputManager = (InputMethodManager) context
						.getSystemService(Context.INPUT_METHOD_SERVICE);
				inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
 
			} 
		} 
 
	} 
 
	// adjust page size based on screen height 
	public int getListPageSize() { 
 
		int listItemsPerPage;
		mySharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.context);