如何修改 simple_list_item_2 上下两个 textview 的字体大小

来源:互联网 发布:php restful 框架 编辑:程序博客网 时间:2024/06/11 13:24

你这相当于自定义了,simpleAdapter没有改变文字大小的操作,你要想简单可以借用他的view,然后在设置他文字大小,代码如下:

  1. class StudentAdapter extends ArrayAdapter<String> {
  2.         LayoutInflater inflator;
  3.         public StudentAdapter(Context context) {
  4.             super(context, 0);
  5.             inflator = LayoutInflater.from(context);
  6.         }
  7.         @Override
  8.         public View getView(int position, View convertView, ViewGroup parent) {
  9.             if (convertView == null) {
  10.                 convertView = inflator.inflate(android.R.layout.simple_list_item_2, parent, false);
  11.             }
  12.             TextView text1 = (TextView) convertView.findViewById(android.R.id.text1);
  13.             TextView text2 = (TextView) convertView.findViewById(android.R.id.text2);
  14.             text1.setTextSize(14);
  15.             text2.setTextSize(12);
  16.             text1.setText("title");
  17.             text2.setText("summary");
  18.             return convertView;
  19.         }
  20.     }
原创粉丝点击