1

使用 Action Bar Sherlock 时,有什么方法可以更改 ActionBar 列表导航的文本颜色?我发现了几篇关于更改标题颜色的帖子,但如果之前有人问过,这没什么好抱歉的。

在常规操作栏上工作正常,但在设备上预蜂窝时,文本是黑底黑字,这使得它不可读。

4

3 回答 3

1

我知道您想更改文本颜色。我假设这是因为黑色/黑色文本或黑色文本上的深灰色文本。

如果是这样,我找到了一个修复预蜂窝设备的解决方案,这些设备存在区分深色文本上的深色的问题

当您声明 SpinnerAdapter 使用: R.layout.sherlock_spinner_item 或 R.layout.sherlock_spinner_dropdown_item

这对我修复蜂窝前设备以及与蜂窝后设备相同的主题很有用。

SpinnerAdapter adapter = ArrayAdapter.createFromResource(this, R.array.navigationArray, R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(adapter, this);

来源:https ://github.com/JakeWharton/ActionBarSherlock/issues/268

于 2013-01-14T21:19:59.387 回答
0

You need create your own example custom_spinner_item

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee" />

and then the dropdown resource custom_spinner_dropdown_item

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="?attr/dropdownListPreferredItemHeight"
    android:ellipsize="marquee" />

you need change the sytle for you own or take the action bar sherlock and modify. an then in your adapter use:

 Context context = getSupportActionBar().getThemedContext();
        ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.locations, custom_spinner_item);
        list.setDropDownViewResource(R.layout.custom_spinner_dropdown_item);

with this you are done ;) this should be used on pre honeycomb:

 Context context = getSupportActionBar().getThemedContext();
        ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.locations, R.layout.sherlock_spinner_item);
        list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
于 2013-01-17T22:51:26.057 回答
0
//in arrays.xml
    <string-array name="solidsFoodSelectionType">
        <item>recent</item>
        <item>all</item>
    </string-array>

//in your class
Context context = getSupportActionBar().getThemedContext();
        String[] typeOfselectionSelected = getResources().getStringArray(R.array.solidsFoodSelectionType);
        typeOfselectionSelectedAdapter = new ArrayAdapter<String>(context,android.R.layout.simple_spinner_dropdown_item,typeOfselectionSelected);
        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        getSupportActionBar().setListNavigationCallbacks(typeOfselectionSelectedAdapter, this);
于 2013-01-09T07:30:28.177 回答