MultiAutoCompleteTextView不会调用onFocusChanged()

问题描述:

当MultiAutoCompleteTextView被轻敲并获得焦点时,需要做一些工作,但似乎侦听器没有被调用。任何想法为什么?下面的代码:MultiAutoCompleteTextView不会调用onFocusChanged()

searchbar.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
     @Override 
     public void onFocusChange(View view, boolean b) { 
      if(b) hide(); 
      else Utils.closeKeyboard(MapsActivity_v2.this, view); 
     } 
    }); 

<MultiAutoCompleteTextView 
       android:imeOptions="actionDone" 
       android:id="@+id/searchbar" 
       android:focusable="true" 
       android:focusableInTouchMode="true" 
       android:background="@android:color/transparent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="@string/search_hint" 
       android:padding="6dp"/> 

添加在XML:

android:focusable="true" 
android:focusableInTouchMode="true" 

代码工作正常。

+0

已经试过了,还没有正常工作 –

+0

是父布局是LinearLayout ?? – Zoffa

+0

RelativeLayout –