2014-03-25 97 views
0

我有一個ListView包含多個EditText。有時候,當我滾動並專注於EditText時,雖然鍵盤正在顯示並且我可以正常輸入字符,但光標消失。當我放置第一個字符時,光標就會出現。ListView中的Edittext丟失光標

<EditText 
      android:id="@+id/et_nutri_lo" 
      android:background="@drawable/edit_text_corner" 
      android:paddingRight="@dimen/et_corner_radius" 
      style="@android:style/TextAppearance.Medium" 
      android:selectAllOnFocus="true" 
      android:layout_width="wrap_content" 
      android:layout_height="@dimen/btn_small_h" 
      android:layout_gravity="center_vertical" 
      android:layout_weight="1" 
      android:minEms="3" 
      android:maxEms="6" 
      android:gravity="right|bottom" 
      android:inputType="numberDecimal" 
      android:filterTouchesWhenObscured="false" 
      /> 

你知道怎麼回事嗎?

謝謝

+0

您能否顯示edittext的屬性? – Sree

+0

@Sreekanthss:我更新了我的EditText上述 – lolyoshi

+0

給這個命令到你的ListView的android:descendantFocusability = 「afterDescendants」 或Android:descendantFocusability = 「beforeDescendants」 – Sree

回答

3

你有沒有機會設置一個OnFocusChangeListener?如果是,請嘗試以下操作:

view.setOnFocusChangeListener(new OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View view, boolean hasFocus) { 
     [YOUR CODE HERE] 
     view.dispatchWindowFocusChanged(hasFocus); // Fix for text selection handle not disappearing 
    } 
}); 
+0

非常準確的答案男人!保持它! –