字体不是发生在定制ArrayAdapter [英] Typeface not taking place in custom ArrayAdapter

查看:118
本文介绍了字体不是发生在定制ArrayAdapter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种风俗阵列适配器:

I having this custom array adapter:

public class CustomAdapter extends ArrayAdapter<DataObj> 
{
int                     layoutResourceId;
List<DataObj>   data;
Activity                activity;
Typeface                iconFont;

public CustomAdapter(Activity activity, int layoutResourceId, List<DataObj> data)
{
    super(activity, layoutResourceId, data);
    this.layoutResourceId = layoutResourceId;
    this.activity = activity;
    this.data = data;
    iconFont = Typeface.createFromAsset(activity.getAssets(), "icons.ttf" );
}

public static class ViewHolder
{
    public TextView icon;
    public TextView name;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) 
{
    View row = convertView;
    ViewHolder holder;

    if (row == null) 
    {
        LayoutInflater layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = layoutInflater.inflate(R.layout.event_type_list_row, null);
        holder = new ViewHolder();
        holder.icon = (TextView) row.findViewById(R.id.layout_icon_EditText);
        holder.name = (TextView) row.findViewById(R.id.layout_name_EditText);
        row.setTag(holder);
    }
    else
    {
        holder = (ViewHolder) row.getTag();
    }
    final DataObj obj = data.get(position);
    if (eventType != null) 
    {
        holder.icon.setText(obj.getIconCode());
        holder.icon.setTypeface(iconFont);
        holder.name.setText(obj.getName());
    }

    return row;
}

}

而不是图标我见code(我用IcoMoon作为我的图标字体)。以静态方式创建我的应用程序图标的其他被视为,但在这里我看到这一点:

有什么不对我的code?

Instead of icon I see code (I am using IcoMoon as my icon font). Other icons in my app that are created statically are seen, But here I see this: what is wrong with my code?

下面是它的工作原理时,它是静态的(这是不是一个图像是IcoMoon的字体):

Here is how it works when it is static (it is not an image it is the font of IcoMoon):

注意:我试图用其他字体(不是图标字体)和它的工作,似乎只有图标字体不工作

Note: I tried to use other fonts (not icon fonts) and it worked, it seems that only icon fonts not working.

推荐答案

什么解决它脱颖而出我是做这样的:

What solved it fore me was to make it like this:

holder.icon.setText(Html.fromHtml(eventType.getIconCode()));

这篇关于字体不是发生在定制ArrayAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆