Как использовать пользовательский шрифт в пользовательском BaseAdapter
Я создаю приложение для Android с помощью Android Studio. У меня есть просмотр списка в деятельности, которая использует пользовательский SimpleAdapter. Мне нужно использовать пользовательский шрифт в пользовательском адаптере, но при попытке он не работает. Нет ошибок, только шрифт не используется. Путь к шрифту работает нормально, когда используется непосредственно в деятельности.
Когда я выхожу из созданного шрифта, я получаю это:
E/====﹕ FONT: android.graphics.Typeface@4c5dfbc0
Это мой специальный код адаптера:
package com.myapp.app.utilities;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.fieldly41.app.R;
import java.util.ArrayList;
import java.util.HashMap;
public class SimpleIconAdapter extends SimpleAdapter {
private ArrayList<HashMap<String, String>> results;
//private Context context;
Typeface font;
public SimpleIconAdapter(Context context, ArrayList<HashMap<String, String>> data, int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
this.results = data;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
View v = view;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.list_item_icon, null);
}
if(results.get(position) != null ) {
Typeface fonter = Typeface.createFromAsset(v.getResources().getAssets(), "fonts/ss-symbolicons-line.ttf");
TextView top_label = (TextView) v.findViewById(R.id.top_label);
TextView icon_label = (TextView) v.findViewById(R.id.icon);
TextView bottom_label = (TextView) v.findViewById(R.id.bottom_label);
icon_label.setText("");
icon_label.setTypeface(fonter);
if (results.get(position).get("locked").equals("false")) {
icon_label.setTextColor(Color.WHITE);
} else {
icon_label.setTextColor(Color.RED);
}
top_label.setText(results.get(position).get("title"));
bottom_label.setText(results.get(position).get("created_at"));
}
return v;
}
}