2013-10-24 19 views
0

Screenshot while pressingListView的背景屬性使當選擇一個

在我的Android應用程序,當用戶按下我的列表中的項目,該項目正確地得到強調藍色高亮顯示的所有項目,但所有的其他項目該列表也會突出顯示爲灰色。當用戶擡起手指時,高光會消失。這會導致整個列表上的「閃爍」效應不受歡迎。

如果我只從ListView中刪除背景屬性,閃爍效果就會消失。我正在尋找另一個修復程序,以便我可以保留背景屬性。

我使用Android的17

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:padding="8dip" 
    android:paddingTop="0dip" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ListView 
     android:textColor="@color/my_sky" 
     android:background="@drawable/my_btn_white" 
     android:id="@+id/my_list" 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1"/> 

    <Button 
     style="@style/MY.Flow.Button" 
     android:id="@+id/my_add_choices" 
     android:text="@string/my_favorites_add_choices" 
     android:layout_marginTop="10dip" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

</LinearLayout> 
+0

我嘗試了android:listSelector =「@ android:color/transparent」和 android:cacheColorHint =「#00000000」,因爲那些在其他線程中被建議,但無濟於事。 – Kris

回答

1

我發現這個問題。我的@繪製/ my_btn_white有如下一行:

<item android:state_pressed="true" android:drawable="@drawable/my_btn_white_active"/> 

當我刪除此行,灰色的亮點,從而閃爍,消失。

0

嘗試添加到您的ListView

android:cacheColorHint="@android:color/transparent" 
+0

這沒有效果。 :( – Kris

+0

它應該工作...你能提供給我們一個屏幕截圖嗎? –

+0

增加。這是與cacheColorHint設置爲#00000000。 – Kris