天天看點

Android打氣筒三種方式

public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        if(convertView==null){
        *方法一
        view = View.inflate(getApplicationContext(),R.layout.item,null);
		
		*方法二
        view =LayoutInflater.from(getApplicationContext()).inflate(R.layout.item,null);
     	
     	*方法三
            LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(R.layout.item, null);
        }
        else
            view=convertView; //控件複用

        return view;
    }