Adapter.getView中inflater.inflate(R.layout.pending_list_item, parent, false);方法处理

RT,最后完成的代码:

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;

		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.pending_list_item,null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		return convertView;
	}



之前我用的是:

inflater.inflate(R.layout.pending_list_item, parent);
程序崩溃.

改成:

inflater.inflate(R.layout.pending_list_item, null);
弹wanring警告:

Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)

最后改成这样了:

inflater.inflate(R.layout.pending_list_item, parent, false);


参考:

http://blog.csdn.net/lxgwm2008/article/details/36376109

你可能感兴趣的:(Android)