Custom Spinner Adapter
The simplest, I think :)
List<String> listOfItems = getListOfItems(); // returns ArrayList<String>
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, listOfItems);
targetSpinner.setAdapter(spinnerAdapter);
Ok, to simply put a list of string in a spinner shouldn't force us to implement an Adapter. That's a code blot and getting a bit pattern crazy, I think.
Trick is the simple_spinner_item id - damn, I like the R.id mechanism but this isn't intuitive from the docs.
Try
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(yourRowlayout, parent,
false);
TextView make = (TextView) row.findViewById(R.id.Make);
Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
"fonts/gilsanslight.otf");
v.setTypeface(myTypeFace);
v.setText(itemList.get(position));
return row;
}
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(yourRowlayout, parent,
false);
TextView make = (TextView) row.findViewById(R.id.Make);
Typeface myTypeFace = Typeface.createFromAsset(context.getAssets(),
"fonts/gilsanslight.otf");
v.setTypeface(myTypeFace);
v.setText(itemList.get(position));
return row;
}
Pass itemList as parameter in super class constructor
public CustomAdapter(Context context, int textViewResourceId,List<CharSequence> itemList) {
super(context, textViewResourceId, itemList);
this.context=context;
this.itemList=itemList;
}