ListFragment片段中的數據,是從Curor中填充的。我把list背景設置為白色,text也設置為白色。我在布局xml中改變 textColor屬性,text的顏色也沒有變。以下是我使用的代碼,我丟失什麼了嗎:
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);
}
list item layout:
<?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" />
代碼錯了吧, 你引用的是android.R.id.text1,但layout裡面是android:id="@+id/spinnerItemText"