Inflate ListView with TreeMap data (Custom Adapter)

扶醉桌前 提交于 2019-12-02 02:36:43

do something like this:

public class TreeMapAdapter extends ArrayAdapter<String> {
    private Context context
    private TreeMap<Integer, Object> treeMap;
    private int mapKeys[];
    public TreeMapAdapter(Context context,TreeMap<Integer, Object> treeMap)
        this.context=context;
        this.treeMao=treeMap;
        mapKeys=treemap.keySet().toArray();
    }

    public int getCount() {
        return treeMap.size();
     }

    public String getItem(int position) {
        return treeMap.get(mapKeys[position]);
    }

    public long getItemId(int position) {
        return mapKeys[position];
    }
    //your getView method....
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!