android SearchView 失去焦点

             @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.fragment_photo_gallery,menu);
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
           // pull out the SearchView
           MenuItem searchItem = menu.findItem(R.id.menu_item_search);
      
           final SearchView searchView = (SearchView)searchItem.getActionView();
       
          
           // get the data from our searchable.xml as a SearchableInfo
           SearchManager searchManager = (SearchManager)getActivity()
               .getSystemService(Context.SEARCH_SERVICE);
           ComponentName name = getActivity().getComponentName();
           SearchableInfo searchInfo = searchManager.getSearchableInfo(name);


           searchView.setSearchableInfo(searchInfo);
        
           searchView.setFocusable(false);
           searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

@Override
public boolean onQueryTextSubmit(String arg0) {
// TODO Auto-generated method stub
searchView.clearFocus();

return false;
}

@Override
public boolean onQueryTextChange(String arg0) {
// TODO Auto-generated method stub
//searchView.setFocusableInTouchMode(true);
return false;
}
});
                   
           searchView.setSubmitButtonEnabled(true);
                  
       }
}

你可能感兴趣的:(android)