Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change text color of search hint in actionbar using support library

I want to change the text color of search view hint, but I tried in many ways with no success. Like in this post: Changing action bar searchview hint text color

I'm using Appcompat, support library of actionbar.

I tried this with null pointer return:

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)); 
like image 834
Leandro Hoffmann Avatar asked Nov 29 '22 15:11

Leandro Hoffmann


1 Answers

Wrong id for the AutoCompleteTextView, I guess. Unless you use a custom Action Bar Search widget. Try smth. like the following:

((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text))
            .setHintTextColor(getResources().getColor(R.color.white));
like image 154
Alexander Zhak Avatar answered Dec 04 '22 21:12

Alexander Zhak