我有一个从光标填充的 ListFragment。我将列表背景设置为白色,出于某种原因,文本也设置为白色。我尝试更改布局 xml 中的 textColor 属性,但似乎没有任何效果。有人能指出我错过了什么吗?谢谢。
从 ListFragment:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] from = {DBConstants.COL_FAMILY_NAME};
int[] to = {android.R.id.text1};
getLoaderManager().initLoader(FAMILY_LOADER, null, this);
adapter = new SimpleCursorAdapter(getActivity().getApplicationContext(), R.layout.simple_spinner_drop_down_view, null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
setListAdapter(adapter);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
registerForContextMenu(getListView());
getListView().setBackgroundResource(android.R.color.white);
getListView().setCacheColorHint(android.R.color.transparent);
}
列表项布局:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerItemText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />