【问题标题】:White text on white background in ListFragment using Theme.Light使用 Theme.Light 的 ListFragment 中白色背景上的白色文本
【发布时间】:2012-01-28 01:08:54
【问题描述】:

我的问题是,我在白色背景上得到白色文本,如下图所示。当我点击它时,文本变黑

这是我的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@id/actionbar"
    style="@style/SPActionBar" />

<fragment
    android:id="@+id/layout_home_list_fragment"
    android:name="at.bartinger.smartphonelib.activity.fragment.ProfileListFragment"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />

<LinearLayout
    android:id="@+id/layout_home_adlayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
</LinearLayout>

ProfileListFragment 扩展了 ListFragment,正如我所说,整个应用程序使用 Theme.Light(在 Manifest xml 中)

【问题讨论】:

  • 默认为黑色
  • 黑底白字。当您将背景更改为白色时。您应该将文本颜色更改为黑色
  • 正如我所说,我正在使用 Theme.Light。它将背景更改为白色,并应将文本颜色更改为黑色,但事实并非如此。我不会手动修改任何东西。全部由主题处理

标签: android list android-fragments


【解决方案1】:

您是否在 SimpleCursorAdapter 中使用它:

getActivity().getApplicationContext() 

如果是,替换为

getActivity().getBaseContext()

它应该可以解决问题。

【讨论】:

  • 在阅读 getBaseContext() 时,听起来应该避免使用它。我可以改用 getView().getContext() 来解决这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-03
  • 2015-08-09
  • 1970-01-01
  • 1970-01-01
  • 2017-04-23
  • 1970-01-01
相关资源
最近更新 更多