相关疑难解决方法(0)

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

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

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

它显示为空值getGroupView.请帮忙.

public class ExpandableListAdapter extends BaseExpandableListAdapter {

    private Context _context;
    private List<String> _listDataHeader; // header titles
    // child data in format of header title, child title
    private HashMap<String, List<String>> _listDataChild;

    public ExpandableListAdapter(Context context, List<String> listDataHeader,
                                 HashMap<String, List<String>> 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 …
Run Code Online (Sandbox Code Playgroud)

android warnings android-layout layout-inflater

218
推荐指数
6
解决办法
8万
查看次数

"避免传递null作为视图根"警告在膨胀视图以供AlertDialog使用时

Avoid passing null as the view root当用nullas 膨胀视图时,我得到了lint警告parent,例如:

LayoutInflater.from(context).inflate(R.layout.dialog_edit, null);
Run Code Online (Sandbox Code Playgroud)

但是,视图是用作一个内容AlertDialog,使用setViewon AlertDialog.Builder,所以我不知道应该传递什么parent.

parent在这种情况下你认为应该是什么?

android layout-inflater android-alertdialog

111
推荐指数
6
解决办法
4万
查看次数