gpt4 book ai didi

android - 使用支持库更改操作栏中搜索提示的文本颜色

转载 作者:太空宇宙 更新时间:2023-11-03 11:28:12 25 4
gpt4 key购买 nike

我想更改搜索 View 提示的文本颜色,但我尝试了很多方法都没有成功。就像在这篇文章中一样:Changing action bar searchview hint text color

我正在使用 Appcompat,支持 actionbar 的库。

我试过用空指针返回:

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

最佳答案

我猜 AutoCompleteTextView 的 ID 错误。除非您使用自定义操作栏搜索小部件。试试像下面这样:

((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text))
.setHintTextColor(getResources().getColor(R.color.white));

关于android - 使用支持库更改操作栏中搜索提示的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18786726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com