android:id="@+id/search_view" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:layout_marginTop="5dp" android:drawableLeft="@drawable/ic_search" android:hint="@string/search_hint" android:inputType="text" android:singleLine="true" android:imeOptions="actionSearch" android:textSize="15sp" /> mSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { ((InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); String str = v.getText().toString(); if (mCurrentFragment == mGroupFragment) { mGroupFragment.setSearchString(str); mGroupFragment.excuteTask(); }else if (mCurrentFragment == mQuanziContactsFragment) { mQuanziContactsFragment.setSearchString(str); mGroupFragment.excuteTask(); } return true; } return false; } });