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

Lea*_*ann 3 android textview android-appcompat android-support-library

我想更改搜索视图提示的文本颜色,但我尝试了很多方面没有成功.就像在这篇文章中:改变动作栏searchview提示文本颜色

我正在使用Appcompat,支持动作栏库.

我尝试使用null指针返回:

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)); 
Run Code Online (Sandbox Code Playgroud)

Ale*_*hak 19

我想是AutoCompleteTextView的错误ID.除非您使用自定义操作栏搜索小部件.试试smth.如下:

((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text))
            .setHintTextColor(getResources().getColor(R.color.white));
Run Code Online (Sandbox Code Playgroud)