我想创建hashmap.how它可能 我希望此类型的hashmap如下所示
{Question=how are you, friend=mack}
{Question=how are you, friend=jack}
{Question=hello, friend=mack}
{Question=hello, friend=jack}
如何从代码下面获取此类地图
map_friend = webservice.getFrend(); //{0=Mack, 1=jack}
map_QUE = webservice.getQuestion();//{0=How are you, 1=hello}
int RQSize = map_QUE.size();
int Isize = map_ITEM.size();
for (i = 0; i < RQSize; i++)
{
rate_map = new HashMap<String, String>();
final String val = map_QUE.get(i);
rate_map.put("Question", val);
mylist.add(rate_map);
for (j = 0; j < Isize; j++)
{
rate_map1 = new HashMap<String, String>();
final String val1 = map_friend.get(j);
rate_map1.put("friend", val1);
mylist1.add(rate_map1);
}
}
mylist和mylist1是arraylist
答案 0 :(得分:1)
如果我理解您的问题,您想知道如何声明地图列表。你可以这样做:
List<Map<String, String>> mylist = new ArrayList<Map<String, String>>();
List<Map<String, String>> mylist1 = new ArrayList<Map<String, String>>();
答案 1 :(得分:1)
Android具有HashMap数据结构。请参阅以下代码并获取想法:
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
list.put("Question=hello", "friend=jack");