Я хотел применить собственный шрифт к моему счетчику. Единственный способ узнать, что создать пользовательский адаптер. Вот мой код
private class CustomAdapter extends ArrayAdapter {
private Context context;
private List<CharSequence> itemList;
public CustomAdapter(Context context, int textViewResourceId,List<CharSequence> itemList) {
super(context, textViewResourceId);
this.context=context;
this.itemList=itemList;
}
public TextView getView(int position, View convertView, ViewGroup parent) {
TextView v = (TextView) super
.getView(position, convertView, parent);
Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
"fonts/gilsanslight.otf");
v.setTypeface(myTypeFace);
v.setText(itemList.get(position));
return v;
}
public TextView getDropDownView(int position, View convertView,
ViewGroup parent) {
TextView v = (TextView) super
.getView(position, convertView, parent);
Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
"fonts/gilsanslight.otf");
v.setTypeface(myTypeFace);
v.setText(itemList.get(position));
return v;
}
}
Затем я использую
List<CharSequence> itemList = new ArrayList<CharSequence>(
Arrays.asList(items));
mySpinnerArrayAdapter = new CustomAdapter(context,android.R.layout.simple_spinner_item,itemList);
spinner.setAdapter(mySpinnerArrayAdapter);
После этого мой адаптер пуст. Кто-нибудь может мне помочь, пожалуйста? Элементы содержат список стран.
С уважением,