我已经使用bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);在actionbar中设置了微调器
然后设置
dropdownValues = getResources().getStringArray(R.array.sortby_array);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.sortby_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
bar.setListNavigationCallbacks(adapter, this);现在我想改变字体样式..所以任何人都可以帮助我,请
发布于 2013-12-28 13:11:21
在您的assets文件夹中创建一个文件夹字体,并将该字体放入该folder.Hope中
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.sortby_array, android.R.layout.simple_spinner_item) {
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
Typeface externalFont=Typeface.createFromAsset(getAssets(), "fonts/your font name here");
((TextView) v).setTypeface(externalFont);
return v;
}
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View v =super.getDropDownView(position, convertView, parent);
Typeface externalFont=Typeface.createFromAsset(getAssets(), "fonts/ your font name here");
((TextView) v).setTypeface(externalFont);
return v;
}
};发布于 2013-12-28 12:54:48
尝尝这个
mLocations = getResources().getStringArray(R.array.locations);
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(context, R.array.locations, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
getSupportActionBar().setListNavigationCallbacks(list, this);创建此R.layout.sherlock_spinner_dropdown_item
发布于 2013-12-28 13:14:21
我已经用SpinnerAdapter做到了这一点。参见代码示例:
public class SpinnerAdapter extends ArrayAdapter<String> {
public SpinnerAdapter(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) {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"fonts/hattori.ttf");
((TextView) view).setTextColor(Color.parseColor("#000000"));
((TextView) view).setTypeface(tf);
((TextView) view).setTextSize(16);
}
return view;
}
}编辑:这不是在ActionBar中,所以不确定它是否工作相同。
https://stackoverflow.com/questions/20811073
复制相似问题