我有一个简单的演示应用程序,只有一个 listActivity,我正在使用 actionBarSherlock。
我的 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 中为我提供了一个蓝色的操作栏,操作栏中的文本为白色,我的 Activity 为白色背景。在 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);
关于如何阻止这种情况发生的任何想法?
最佳答案
您好@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" />
关于android - ListView 在 2.x 上改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17938729/