android - ListView 在 2.x 上改变颜色

标签 android android-listview actionbarsherlock simpleadapter

我有一个简单的演示应用程序,只有一个 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/

相关文章:

android - 在自定义警报对话框中获取单选按钮的值

android-listview - 替换片段时无法在 PagerSlidingTabStrip 中加载选项卡

android - 如何在android中的自定义 ListView 中实现搜索?

android - onRestoreInstanceState 中的 NullPointerException

android - 添加 Paypal SDK 后增加 apk 文件的大小

android:将字体图标显示为数字字符串序列

android - Gradle 4.9 + Lombok 1.18.0 失败

java - fragment View 上 AsyncTask 中的 setContentView() 问题

android - 无法使用 ActionBarSherlock 库

android - 删除 actionbarsherlock 中的项目边框