看代码 很简单 不解释
SpinnerAdapter mAdapter = new SpinnerAdapter(UploadVideoActivity.this,android.R.layout.simple_list_item_1, videoTypes);
mSpinner.setAdapter(mAdapter);
public class SpinnerAdapter extends ArrayAdapter {
Context context;
String[] items = new String[] {};
int textViewResourceId ;
int textSize = 18;
public SpinnerAdapter(final Context context,
final int textViewResourceId, final String[] objects) {
super(context, textViewResourceId, objects);
this.items = objects;
this.context = context;
this.textViewResourceId = textViewResourceId;
}
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(textViewResourceId, parent, false);
}
TextView tv = (TextView) convertView
.findViewById(android.R.id.text1);
tv.setText(items[position]);
tv.setTextSize(textSize);
return convertView;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(textViewResourceId, parent, false);
}
// android.R.id.text1 is default text view in resource of the android.
// android.R.layout.simple_spinner_item is default layout in resources of android.
TextView tv = (TextView) convertView.findViewById(android.R.id.text1);
tv.setText(items[position]);
tv.setTextSize(textSize);
return convertView;
}
}