2012-10-23 44 views
0

我寫適配器改變焦點適配器

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 
... 
    <EditText 
     android:id="@+id/weight" 
     android:layout_width="55dp" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="15dp" 
     android:ems="10" 
     android:inputType="number" 
     android:textSize="14sp" > 
    </EditText> 
... 
</LinearLayout> 

,並把它添加到我的名單。在適配器我添加了一個textWatcher體重的EditText像下面

holder.weight.addTextChangedListener(new TextWatcher() { 
     @Override 
     public void onTextChanged(CharSequence s, int start, int before, 
       int count) { 
     } 

     @Override 
     public void beforeTextChanged(CharSequence s, int start, int count, 
       int after) { 
     } 

     @Override 
     public void afterTextChanged(Editable s) { 
      if (s.length() != 0) 
       try { 
       // ... 
       } catch (IndexOutOfBoundsException e) { 
        Log.e(TAG, e.toString()); 
       } 

     } 
    }); 

代碼,但是當我選擇在列表中的行更改數值中的EditText重點從EditText上和鍵盤就設置爲默認情況下,當我選擇我的EditText一個更多的時間,當一切運作良好。 我應該如何解決它的重點不跳?

回答

0

我不知道,但如果嘗試這種你的注意力越來越變化

holder.qty.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
public void onFocusChange(View v, boolean hasFocus) { 
    // TODO Auto-generated method stub 
    final EditText qty = (EditText) v; 
    qty.setFocusableInTouchMode(true); 
    qty.setFocusable(true); 
    StaticData.cartdata.get(position).qty = qty.getText().toString(); 
} 

});