Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的N级可扩展列表_Android - Fatal编程技术网

android中的N级可扩展列表

android中的N级可扩展列表,android,Android,我在我的项目中实现了n级消耗清单,但我无法找到内部消耗清单的实际大小。例如,一级消耗品列表中有4个子项,当我点击一级物品时,它显示正确,他们又有4个子项,但我只能看到2或3个子项。我与您共享我的代码,请帮助我 这是我的ExpandableListAdapter类: public class ExpandableListAdapter extends BaseExpandableListAdapter { Context context; LinkedHashMap objhashTable;

我在我的项目中实现了n级消耗清单,但我无法找到内部消耗清单的实际大小。例如,一级消耗品列表中有4个子项,当我点击一级物品时,它显示正确,他们又有4个子项,但我只能看到2或3个子项。我与您共享我的代码,请帮助我

这是我的ExpandableListAdapter类:

public class ExpandableListAdapter extends BaseExpandableListAdapter {
Context context;
LinkedHashMap objhashTable;

public ExpandableListAdapter(Context con, LinkedHashMap objhashTable) {
    // TODO Auto-generated constructor stub
    this.context = con;
    this.objhashTable = objhashTable;
    Log.i("ParentView", "objhashTable  == " + objhashTable.size());
    // nu

}

@Override
public Object getChild(int arg0, int arg1) {
    return arg1;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public View getChildView(int groupPosition, int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {
    //Log.i("ParentView", "getChildView  == " + childPosition
        //  + "  groupPosition  == " + groupPosition+"   parent  == "+conve);
    //parent.
    LinkedHashMap temp = getSelectedObject(groupPosition);
    if (temp != null && getSelectedObject(groupPosition) != null ) {
        ExpandableListAdapter parebnt = new ExpandableListAdapter(context, temp);
        LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.expendablelist, parent, false);
        ExpandableListView NextLevelAdapter =(ExpandableListView)convertView.findViewById(R.id.ParentLevel123);
        TextView txt = (TextView)convertView.findViewById(R.id.txtLevel);
        txt.setText(getSelectedKey(groupPosition) );
        txt.setTextColor(Color.BLACK);
        txt.setTag(getSelectedKey(groupPosition));
        txt.setTextSize(20);
        txt.setBackgroundColor(Color.BLUE);
        txt.setPadding(10, 7, 7, 7);
        //CustExpListview SecondLevelexplv = new CustExpListview(context);
        NextLevelAdapter
                .setAdapter(/* new SecondLevelAdapter(context) */parebnt);
        NextLevelAdapter.setGroupIndicator(null);
        convertView.measure( MeasureSpec.AT_MOST, MeasureSpec.AT_MOST );
         convertView.getLayoutParams().height = convertView.getMeasuredHeight();
        return convertView;
    }else{
        return null;

    }
}



@Override
public Object getGroup(int groupPosition) {
    return groupPosition;
}

@Override
public int getGroupCount() {
    //if (objhashTable != null ) 
    //Log.i("ParentLevel", "objhashTable == "+objhashTable);
           return objhashTable.size();

}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}



@Override
public boolean hasStableIds() {
    return true;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}

private LinkedHashMap getSelectedObject(int groupPos) {
    LinkedHashMap lnmap = null;
    if (objhashTable != null) {
        Iterator it = objhashTable.keySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            String type = (String) it.next();
            if (i == groupPos) {
                lnmap = (LinkedHashMap) objhashTable.get(type);
                // childCount =lnmap.size();
                break;
            }
            i++;
        }

    }
    return lnmap;
}

private String getSelectedKey(int groupPos) {
    String type = null;
    if (objhashTable != null) {
        Iterator it = objhashTable.keySet().iterator();
        int i = 0;
        while (it.hasNext()) {
            type = (String) it.next();
            if (i == groupPos) {
                // lnmap = (LinkedHashMap)objhashTable.get(type);
                // childCount =lnmap.size();
                break;
            }
            i++;
        }

    }
    return type;
}

@Override
public int getChildrenCount(int groupPosition) {
    // TODO Auto-generated method stub
    return 1;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded,
        View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    return null;
}
}