2017-12-15 32 views
1

나는 searchview를 가지고 있으며 어떤 시점에서 searchview.I에서 현재 초점을 맞춘보기를 얻고 싶습니다. API를 사용하여 이것을 달성하려고합니다 Activity.getCurrentfocus() or getWindow.getDecorView.FindFocus(). 그러나 API는 모두 이며 null 인 경우입니다. searchview에는 포커스가 있지만입니다.현재 초점을 맞춘 메뉴 항목을 얻는 방법

내 질문은 현재 포커스 된보기를 옵션 메뉴/searchview에서 가져 오는 방법입니까?

답변

0

문서 :

View getCurrentFocus()

돌아 은 아무도가없는 경우 현재 초점 는 null을 가지고이 창에서보기를. 이것은 포함 된 창을 보지 않습니다.

당신은 onQueryTextSubmit

@Override 
    public boolean onQueryTextSubmit(String query) 
     // Get the focus of the SearchView 
     View current = getCurrentFocus(); 
     if (current != null) 
      // Has focus 
     else 
      // No focus 

     return false; 
    } 
getCurrentFocus()를 호출하여 디버깅 할 수 있습니다