搜索查看的文本颜色的动作条与ActionBarSherlock [英] Text color of SearchView in ActionBar with ActionBarSherlock

查看:105
本文介绍了搜索查看的文本颜色的动作条与ActionBarSherlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要改变文本的颜色在ActionBarSherlock 搜索查看,所以我发现这对计算器:

I want to change the color of a text in an ActionBarSherlock SearchView, so I found this on StackOverflow:

AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
searchText.setHintTextColor(getResources().getColor(R.color.white));
searchText.setTextColor(getResources().getColor(R.color.white));    

但问题是, searchText 始终为空。我也试图与 search_src_text (没有 ABS __ ) - 再次, searchText

But the problem is that searchText is null always. Also I tried with search_src_text (no abs__) - again, searchText is null.

我用夏洛克我的动作条(具有用于动作条自定义视图),但我也想改变搜索视图的文本颜色。

I use Sherlock for my ActionBar (having custom view for the actionbar) but I also want the text color of the search view to be changed.

什么我不明白?

推荐答案

修改并应用样式如下:

  1. 覆盖 SearchViewStyle 定义相关的风格。

<style name="SearchViewStyle" 
       parent="Widget.Sherlock.Light.SearchAutoCompleteTextView">
    <item name="android:textColor">myTextColor</item>
</style>

  • 将此样式定义您的应用程序的主题。

  • Add this style definition to your app theme.

    <style name="CustomTheme" parent="Theme.Sherlock.Light">
        ...
        <item name="searchAutoCompleteTextView">@style/SearchViewStyle</item>
        ...
    </style>
    

  • 在你的清单应用这个主题。(安卓主题=CustomTheme

    希望这有助于...干杯!

    Hope this helps ... Cheers!

    PS 的搜索 SearchViewStyle 在ABS的样式定义(XML文件)。这样,您就可以使用Ctrl +单击定义跟进可用的样式。

    p.s. search for SearchViewStyle in ABS style definitions (XML files). This way you can follow up available styles using Ctrl+click on definitions.

    这篇关于搜索查看的文本颜色的动作条与ActionBarSherlock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆