android 布局作为参数,android - 避免传递null作为视图根(需要解析膨胀布局的根元素上的布局参数)...

为root studio传递null给了我这个警告:

避免将null作为视图根传递(需要解析膨胀布局的根元素上的布局参数)

它在getGroupView中显示为空值。请帮助。

public class ExpandableListAdapter extends BaseExpandableListAdapter {

private Context _context;

private List _listDataHeader; // header titles

// child data in format of header title, child title

private HashMap> _listDataChild;

public ExpandableListAdapter(Context context, List listDataHeader,

HashMap> listChildData) {

super();

this._context = context;

this._listDataHeader = listDataHeader;

this._listDataChild = listChildData;

}

@Override

public Object getChild(int groupPosition, int childPosititon) {

return this._listDataChild.get(this._listDataHeader.get(groupPosition))

.get(childPosititon);

}

@Override

public long getChildId(int groupPosition, int childPosition) {

return childPosition;

}

@Override

public View getChildView(int groupPosition, final int childPosition,

boolean isLastChild, View convertView, ViewGroup parent) {

final String childText = (String) getChild(groupPosition, childPosition);

if (convertView == null) {

LayoutInflater infalInflater = (LayoutInflater) this._context

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

convertView = infalInflater.inflate(R.layout.list_item, null);

}

TextView txtListChild = (TextView) convertView

.findViewById(R.id.lblListItem);

txtListChild.setText(childText);

return convertView;

}

@Override

public int getChildrenCount(int groupPosition) {

return this._listDataChild.get(this._listDataHeader.get(groupPosition))

.size();

}

@Override

public Object getGroup(int groupPosition) {

return this._listDataHeader.get(groupPosition);

}

@Override

public int getGroupCount() {

return this._listDataHeader.size();

}

@Override

public long getGroupId(int groupPosition) {

return groupPosition;

}

@Override

public View getGroupView(int groupPosition, boolean isExpanded,

View convertView, ViewGroup parent) {

String headerTitle = (String) getGroup(groupPosition);

if (convertView == null) {

LayoutInflater infalInflater = (LayoutInflater) this._context

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

convertView = infalInflater.inflate(R.layout.list_group, null);

}

TextView lblListHeader = (TextView) convertView

.findViewById(R.id.lblListHeader);

lblListHeader.setTypeface(null, Typeface.BOLD);

lblListHeader.setText(headerTitle);

return convertView;

}

@Override

public boolean hasStableIds() {

return false;

}

@Override

public boolean isChildSelectable(int groupPosition, int childPosition) {

return true;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值