如何更改搜索视图建议的字体?

时间:2015-06-18 12:36:13

标签: android searchview

我搜索了几个小时他们建议使用自定义游标适配器。但我正在使用内容提供程序填写建议,并没有任何游标适配器。我现在能够找到AutoCompleteTextView并更改可编辑文本视图的字体,但我想对建议执行相同的操作。我该怎么办?

2 个答案:

答案 0 :(得分:1)

您可以从sdk获取textview的句柄,然后更改它,因为它们不公开公开。

试试这段代码:

int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
TextView textView = (TextView) searchView.findViewById(id);
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Kokila.ttf"); 
textView.setTypeface(type);

答案 1 :(得分:0)

要更改文字字体,您必须实施自己的CursorAdapter,并在bindView()方法中获取对TextView的引用,并使用TextView.setTypeface()应用字体。< / p>

相关问题