Code example for SearchView

Methods: setIconifiedsetQuery

0
	@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
	public static void collapseSearchView(SearchView sv, Menu menu, int menuItemId) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			menu.findItem(menuItemId).collapseActionView();
		} else { 
			sv.setQuery(null, false);
			sv.setIconified(true);
		} 
	} 
 
	public static ProgressDialog createProgressDialog(Context context, int messageStringId) {
		ProgressDialog d = new ProgressDialog(context);
		d.setMessage(context.getString(messageStringId));
		return d;
	} 
 
	public static TextView createTextView(Context context, int layoutId, int stringId) {
		TextView t = (TextView) View.inflate(context, layoutId, null);
		t.setText(stringId);
		return t;