我只想更改微调器文本的字体和大小。
我做了一些初步的尝试。没有什么崩溃,但我的微调器是空白的。(我还没有实现自定义字体,我只是想让微调器先工作。
在代码中:
protected SpinnerSortAdapter sAdapter;
protected Spinner sort;
protected String[] strings;
sort = (Spinner) getActivity().findViewById(R.id.spinner2);
strings = getActivity().getResources().getStringArray(R.array.sorting_items);
SpinnerSortAdapter sAdapter = new SpinnerSortAdapter(getActivity(),
android.R.layout.simple_spinner_item, strings);
sAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sort.setAdapter(sAdapter);
sort.setOnItemSelectedListener(new MyOnItemSelectedListener());
适配器:
public class SpinnerSortAdapter extends ArrayAdapter<String> {
public SpinnerSortAdapter(Context context, int textViewResourceId,
String[] strings) {
super(context, textViewResourceId, strings);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
if (view instanceof TextView) {
((TextView) view).setTextSize(5);
}
return view;
}
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View row = super.getView(position, convertView, parent);
return (row);
}
}enter code here