1

我有一個簡單的演示應用程序只有一個listActivity,我使用的是actionBarSherlock。ListView更改2.x的顏色

我styles.xml是:

<resources> 

    <style name="AppBaseTheme" parent="Theme.Sherlock"></style> 

    <style name="AppTheme" parent="AppBaseTheme"> 
     <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item> 
     <item name="android:actionBarStyle">@style/Widget.MyTheme.ActionBar</item> 
     <item name="android:windowBackground">@android:color/white</item> 
    </style> 

    <style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar"> 
     <item name="android:background">#388E8E</item> 
     <item name="background">#388E8E</item> 
    </style> 

</resources> 

這種風格讓我在2.x和3.x藍色的動作條白字的操作欄和一個白色背景上我的活動。在Android 2.x和4.x上看起來很完美。問題是,在2.x中,當我滾動時,我得到一個黑色的背景。我目前正在使用SimpleAdapter:

int[] ids = { android.R.id.text1, android.R.id.text2 }; 
SimpleAdapter adapter = new SimpleAdapter(this, aList, android.R.layout.simple_list_item_2, from, ids); 

有關如何阻止這種情況發生的任何想法?

+0

指以下鏈接。 [1]:http://stackoverflow.com/questions/2792976/android-listview-produces-black-highlighting-over-text-when-scrolling-how-to-st [2]:HTTP: //stackoverflow.com/questions/14909686/fragment-inside-scrollview-gives-black-background-flickering – hharry

回答

2

嗨@EGHDK這是您的列表頁面問題。在listView節點中追加android:cacheColorHint =「#00000000」。例如 <ListView android:id="@+id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/somecolor" android:divider="@android:color/transparent" android:cacheColorHint="#00000000" />