Android 值为列表的ListView和Map

Android 值为列表的ListView和Map,android,android-listview,Android,Android Listview,有没有办法从中填充android ListView Map<Integer, List<Object>> 研究适配器: private class StudiesAdatper extends BaseAdapter { private Map<Integer, List<Study>> map; private Context context; private int day = 0; public Stu

有没有办法从中填充android ListView

Map<Integer, List<Object>> 
研究适配器:

private class StudiesAdatper extends BaseAdapter {

    private Map<Integer, List<Study>> map;
    private Context context;
    private int day = 0;

    public StudiesAdatper(Context context, Map<Integer, List<Study>> map) {
        this.context = context;
        this.map = map;
    }

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

        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.day_row, null);
        }


        if (map.get(day) == null) {
            day++;
            return convertView;
        }

        Study study = map.get(day++).get(position);
        /* 
         * Working with study here
         */
        return convertView;

    }

    @Override
    public int getCount() {
        return map.size();
    }
}
Listls=(List)map.get(day++);
如果(ls.size()-1>=位置){
学习=map.get(day++)、get(position);
}

使用ExpandableListView找到了解决方案

下面是一个例子,我很容易为Map重新制作


您遇到了什么错误?IndexOutOfBoundsException。是的,这修复了错误,但map的主要思想不起作用。。。这段代码并没有显示它的所有元素。我认为唯一的方法是将所有地图元素合并到一个列表中。。。但是,无论如何,多亏了你。所以列表没有按预期的方式填充?是的,它只填充了来自映射第一个键的一些(不是全部)值。
private class StudiesAdatper extends BaseAdapter {

    private Map<Integer, List<Study>> map;
    private Context context;
    private int day = 0;

    public StudiesAdatper(Context context, Map<Integer, List<Study>> map) {
        this.context = context;
        this.map = map;
    }

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

        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.day_row, null);
        }


        if (map.get(day) == null) {
            day++;
            return convertView;
        }

        Study study = map.get(day++).get(position);
        /* 
         * Working with study here
         */
        return convertView;

    }

    @Override
    public int getCount() {
        return map.size();
    }
}
FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Invalid index 3, size is 3
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
**
List<Study>ls=(List<Study>)map.get(day++);
if(ls.size()-1>=position){
   Study study = map.get(day++).get(position);
}