【问题标题】:android hashmap storing object variable within objectandroid hashmap在对象中存储对象变量
【发布时间】:2012-08-30 23:01:14
【问题描述】:

嘿,我正在尝试将一些值存储在 hashmap 中以放入 自定义视图。 问题是在我的hashmap 的 put 方法中分配 keys 时,当我尝试从变量中获取 key 时,我得到一个 error在与我的另一个对象在一起的对象中

这是我的代码:

     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);

日志猫:

【问题讨论】:

  • 你在尝试自定义列表视图
  • 您遇到了什么错误?我假设它是RuntimeException 你能提供来自 LogCat 的跟踪吗?
  • 请提供您的“错误”的堆栈跟踪。
  • 我已经提供了logcat信息
  • 为什么要发布图片?你不能通过复制/过去吗?

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


【解决方案1】:

好像

a.kunde

为空

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-28
    相关资源
    最近更新 更多