0

我正在实施SimpleAdapter这样的:

    List<Map> data = getDrawerData();
    SimpleAdapter adapter = new SimpleAdapter(this, data,R.layout.drawer_list_item,new String[] {"drawer_icon","drawer_text"},new int[] {R.id.drawer_icon, R.id.drawer_text});

但是,第二行给了我这个错误:

构造函数 SimpleAdapter(MainActivity, List, int, String[], int[]) 未定义

Two fixes

1. Cast argument 'data' to 'List<? extends Map<String, ?>>'或者 2. Change type of 'data' to 'List<? extends Map<String, ?>>'

我选择了该Cast选项,但这仅显示抽屉列表项的图标,而不是它们的TextView标签...

我跟着这个教程:http ://shenhengbin.wordpress.com/2012/03/17/listview-simpleadapter/

4

1 回答 1

0

根据此示例,我使用了自定义适配器。我在该链接中遇到了一个错误(“变量必须提供维度表达式或数组”):

    Weather weather_data[] = new Weather[] // << HERE
    {
        new Weather(R.drawable.weather_cloudy, "Cloudy"),
        new Weather(R.drawable.weather_showers, "Showers"),
        new Weather(R.drawable.weather_snow, "Snow"),
        new Weather(R.drawable.weather_storm, "Storm"),
        new Weather(R.drawable.weather_sunny, "Sunny")
    };

我将其更改Weather weather_data[] = new Weather[NUM_OF_ITEMS]为修复它:) 希望这对某人有所帮助。

于 2013-08-31T21:31:37.097 回答