android hashmap在对象中存储对象变量

时间:2012-09-06 07:12:33

标签: android android-layout hash hashmap key-value

嘿我想在hashmap中存储一些值以放入自定义视图。 问题是在我hashmap的put方法中分配时,当我尝试从获取错误时一个与我的另一个对象相关的对象中的变量

这是我的代码:

     ListView lv= (ListView)findViewById(R.id.listView1);
     String[] from = new String[] {"fornavn", "starttid", "sluttid"};
     int[] to = new int[] { R.id.Kunde, R.id.StartTime, R.id.EndTime };     

     List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>(); 

     for(Appointment a : todayList)     {

        HashMap<String, String> map = new HashMap<String, String>();

            //here is my error I don't know what to put as key??
        map.put("kunde.fornavn", "col_1_item_" + a.kunde.fornavn);
        map.put("starttid", "col_2_item_" + String.valueOf(a.startTime));
        map.put("sluttid", "col_3_item_" + String.valueOf(a.endTime));
        fillMaps.add(map);

     }
     SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.row, from, to);
     lv.setAdapter(adapter);

logcat的:

LogcatInfo

1 个答案:

答案 0 :(得分:0)

似乎

a.kunde

为空