请教listview怎么设置字体大小
1个回答
展开全部
ListView list = (ListView) findViewById(R.id.list);
adapter = new MyAdapter(this,R.layout.main,
R.id.row_text,
new String[]{"Uno", "Dos", "Tres"} );
list.setAdapter(adapter);
//Custom Adapter class
private class MyAdapter extends ArrayAdapter<String>{
String[] mStrings;
LayoutInflater mInflater;
public MyAdapter(Context context, int resource, int textViewResourceId,
String[] strings) {
super(context, resource, textViewResourceId, strings);
mStrings = strings;
mInflater = (LayoutInflater) FirstAct.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = mInflater.inflate(R.layout.main,null, false);
TextView text = (TextView) view.findViewById(R.id.row_text);
text.setText(mStrings[position]);
Spannable str = (Spannable) text.getText();
str.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return view;
}
}
adapter = new MyAdapter(this,R.layout.main,
R.id.row_text,
new String[]{"Uno", "Dos", "Tres"} );
list.setAdapter(adapter);
//Custom Adapter class
private class MyAdapter extends ArrayAdapter<String>{
String[] mStrings;
LayoutInflater mInflater;
public MyAdapter(Context context, int resource, int textViewResourceId,
String[] strings) {
super(context, resource, textViewResourceId, strings);
mStrings = strings;
mInflater = (LayoutInflater) FirstAct.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = mInflater.inflate(R.layout.main,null, false);
TextView text = (TextView) view.findViewById(R.id.row_text);
text.setText(mStrings[position]);
Spannable str = (Spannable) text.getText();
str.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return view;
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询