TabHost 和 FontAwesome 图标

TabHost and FontAwesome Icons

如何 return 将超赞字体图标添加到 tabhost 的标题选项卡?现在它什么都不显示.....我下面的方法适用于 PagerTabStrip 有什么区别?

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/fontawesome-webfont.ttf");
    // create the TabHost that will contain the Tabs
    TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
    TabHost.TabSpec tab1 = tabHost.newTabSpec("tab1");

    //this wont show the icon, it's blank:
    tab1.setIndicator(icon_giver(font,  "\uf0c0"));




//my method is:

public CharSequence icon_giver(Typeface font, String icon_id){
    String title_of_page = "";
    SpannableStringBuilder styled;
    title_of_page = icon_id;
    styled = new SpannableStringBuilder(title_of_page);
    styled.setSpan(new CustomTypefaceSpan("", font), 0, title_of_page.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
    return styled;
}

好的,所以我不得不这样做:

TextDrawable 项目 github。您可以修改它,使用 Font-Awesome 作为字体。

我通过以下方式应用它:

TextDrawable draw_icon = new TextDrawable(this);
draw_icon.setText(icon_giver(font, "\uf0c0"));
tab1.setIndicator("",draw_icon);