如何在BaseAdapter的GetView()方法中迭代Map值?

时间:2017-01-05 06:40:57

标签: java android android-adapter baseadapter

我正在尝试解析以下Json。

XCDYouTubeKit

My BaseAdapter仅显示ListView中的第一个Item。我正在尝试在Map中检索值。在迭代期间,值将被覆盖。当我打印值时,它正确打印。

MyContactAdapter2.java

{
"effect_list": [{
      "1":[  
         {  
            "effects_id":"1",
            "effects_name":"Band 1"
         },
         {  
            "effects_id":"2",
            "effects_name":"Band 2"
         }


      ],
      "2": [ 
         {  
            "effects_id":"4",
            "effects_name":"Background Blur"
         },
         {  
            "effects_id":"5",
            "effects_name":"Blemish Removal"
         }
      ] 
   }]
}

所以我的问题是,如何在“BaseAdapter”中迭代“GetView()”中的“Map”值?

是否可以在BaseAdapter中的 GetView()方法中迭代值?

1 个答案:

答案 0 :(得分:2)

你做不到:

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

    final Map<String, List<EffectList>> effectMap = getItem(position);

    for (Map.Entry<String, List<EffectList>> entry : effectMap.entrySet()) {
        final String key = entry.getKey();
        final List<EffectList> value = entry.getValue();
        // ... do stuff ...
    }

    // ... blah blah 
}

相关问题