我正在使用SearchRecentSuggestionsProvider在搜索视图中显示最近的建议,但建议的文字颜色是白色,我想成为黑色,有没有办法做到这一点......任何帮助请
import android.content.SearchRecentSuggestionsProvider;
public class MySuggestionProvider extends SearchRecentSuggestionsProvider {
public final static String AUTHORITY = "com.example.saleh.mysqlserver.helper.MySuggestionProvider";
public final static int MODE = DATABASE_MODE_QUERIES| DATABASE_MODE_2LINES;
public MySuggestionProvider() {
setupSuggestions(AUTHORITY, MODE);
}
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_search_friend, menu);
this.menu=menu;
SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView search = (SearchView) menu.findItem(R.id.action_search).getActionView();
search.setIconifiedByDefault(false);
search.requestFocus();
search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
SearchView.SearchAutoComplete autoCompleteTextView = (SearchView.SearchAutoComplete)
search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
autoCompleteTextView.setTextColor(Color.WHITE);
int count=search.getSuggestionsAdapter().getCount();
Toast.makeText(this,""+count,Toast.LENGTH_SHORT).show();
for (int i=0;i<count;i++){
View mView= search.getSuggestionsAdapter().getView(i, null, null);
mView.setBackgroundColor(Color.BLACK);
}
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
SearchRecentSuggestions suggestions=new SearchRecentSuggestions(SearchFriendActivity.this
, MySuggestionProvider.AUTHORITY,
MySuggestionProvider.MODE);
suggestions.saveRecentQuery(query,"");
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
// loadHistory(newText);
return false;
}
});
return true;
}