代码中的注释就是我想问的问题了,帮忙解答解答谢了 public View getView(int position, View convertView, ViewGroup parent) {

LinearLayout linearlayout; Example example = getItem(position);
String tv1_str = example.getSex();
String tv2_str = example.getName(); if (convertView == null) {         //这个convertView是什么意思,做什么用的

linearlayout = new LinearLayout(getContext());
LayoutInflater vi;
vi = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
vi.inflate(resource, linearlayout, true); //inflate这个方法官方API看不懂,指教
} else {

linearlayout = (LinearLayout) convertView;
}
TextView tv1 = (TextView) findViewById(R.id.tv1);
TextView tv2 = (TextView) findViewById(R.id.tv2);
tv1.setText(tv1_str);
tv1.setText(tv2_str);
return linearlayout;//这里返回的是社么对象?
} }

解决方案 »

  1.   

    1.convertView即ListView中的每一个Item
    其他的一起等解
      

  2.   

    当ListView滑动的过程中 会有item被滑出屏幕 而不再被使用 这时候Android会回收这个条目的view 
    这个view也就是这里的convertView
      

  3.   

    最后返回的其实也就是那个convertView对象。linearlayout = (LinearLayout) convertView;
      

  4.   

    LayoutInflater这个类的作用类似于findViewById(),不同点是LayoutInflater是用来找layout下xml布局文件,并且实例化!而findViewById()是找具体xml下的具体widget控件(如:Button,TextView等)。