Code example for SpinnerAdapter

Methods: getCount

0
    return layoutInflater.inflate(nothingSelectedDropdownLayout, parent, false);
} 
 
@Override 
public int getCount() { 
    int count = adapter.getCount();
    return count == 0 ? 0 : count + EXTRA;
} 
 
@Override 
public Object getItem(int position) {
    return position == 0 ? null : adapter.getItem(position - EXTRA);
} 
 
@Override 
public int getItemViewType(int position) {
    // doesn't work!! Vote to Fix! http://code.google.com/p/android/issues/detail?id=17128 - Spinner does not support multiple view types 
    // This method determines what is the convertView, this should return 1 for pos 0 or return 0 otherwise.  
    return position == 0 ? getViewTypeCount() - EXTRA : adapter.getItemViewType(position - EXTRA);
}