2016-07-27 5 views
-1

사용자가 AutoComplateTextView 항목을 클릭 할 때 소프트웨어 키보드를 숨기려고하는데 작동하지 않습니다.AutoComplateTextView 항목을 클릭 할 때 키보드 숨기기

mAutoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
     @Override 
     public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
     /** 
     * do something 
     */ 
      InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
       inputManager.hideSoftInputFromInputMethod(mAutoCompleteTextView.getWindowToken(), 0); 
     } 
    }); 

답변

3

넣어 온 클릭 방법이 코드는 :

InputMethodManager inputManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); 

    View v = getActivity().getCurrentFocus(); 

    if (v != null) { 

     getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 

     inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 

    } 
+0

감사를 넣어, 지금은 작동

이 내 코드입니다! – Jacek

+0

환영합니다,이 대답을 정답으로 표시하십시오 –

+0

우수, 작동합니다 .. !!! 고맙습니다! –

0
View view = this.getCurrentFocus(); 
if (view != null) { 
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
} 

당신의 클릭 이벤트에

관련 문제