赞
踩
项目中需要用到listview,而Android 默认的listView 控件是不支持更改字体颜色,字体大小的。抽空写了一个小demo测试下
代码如下:
//listview适配器,调整字体大小、颜色等
private class MyAdapter extends BaseAdapter{
@Override
public int getCount() {
// TODO Auto-generated method stub
return monitor.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView mTextView = new TextView(getApplicationContext());
mTextView.setText(monitor[position]);
mTextView.setTextSize(15);
mTextView.setTextColor(Color.BLUE);
return mTextView;
}
}
效果图如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。