2011-09-13 27 views

回答

3

這是一個非常煩人的問題,出於某種原因可能與您正在使用的主題有關。我不確定究竟是什麼根源,但是這裏有一個解決方法(出現在Android平臺本身中),這對我來說很有效。

<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> 
    <item android:state_focused="true" android:state_pressed="true" 
     android:drawable="@drawable/list_selector_background_transition" /> 
    <item android:state_focused="false" android:state_pressed="true" 
     android:drawable="@drawable/list_selector_background_transition" /> 

(從list_selector_background.xml拍攝)

注意,Android平臺的開發者似乎也有遇到這個問題,他們有一個解決方法是重新使用了不同的選擇狀態相同的背景資源。顯然,觸發一個重新驗證的調用來解決問題(至少對我而言)。