Android – MapView包含在Listview中

前端之家收集整理的这篇文章主要介绍了Android – MapView包含在Listview中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
目前我正试图在ListView中放置一个MapView.有没有人有这样的成功?甚至有可能吗这是我的代码
  1. ListView myList = (ListView) findViewById(android.R.id.list);
  2. List<Map<String,Object>> groupData = new ArrayList<Map<String,Object>>();
  3.  
  4. Map<String,Object> curGroupMap = new HashMap<String,Object>();
  5. groupData.add(curGroupMap);
  6. curGroupMap.put("ICON",R.drawable.back_icon);
  7. curGroupMap.put("NAME","Go Back");
  8. curGroupMap.put("VALUE","By clicking here");
  9.  
  10. Iterator it = data.entrySet().iterator();
  11. while (it.hasNext())
  12. {
  13. //Get the key name and value for it
  14. Map.Entry pair = (Map.Entry)it.next();
  15. String keyName = (String) pair.getKey();
  16. String value = pair.getValue().toString();
  17.  
  18. if (value != null)
  19. {
  20. //Add the parents -- aka main categories
  21. curGroupMap = new HashMap<String,Object>();
  22. groupData.add(curGroupMap);
  23.  
  24. //Push the correct Icon
  25. if (keyName.equalsIgnoreCase("Phone"))
  26. curGroupMap.put("ICON",R.drawable.phone_icon);
  27. else if (keyName.equalsIgnoreCase("Housing"))
  28. curGroupMap.put("ICON",R.drawable.house_icon);
  29. else if (keyName.equalsIgnoreCase("Website"))
  30. curGroupMap.put("ICON",R.drawable.web_icon);
  31. else if (keyName.equalsIgnoreCase("Area Snapshot"))
  32. curGroupMap.put("ICON",R.drawable.camera_icon);
  33. else if (keyName.equalsIgnoreCase("Overview"))
  34. curGroupMap.put("ICON",R.drawable.overview_icon);
  35. else if (keyName.equalsIgnoreCase("Location"))
  36. curGroupMap.put("ICON",R.drawable.map_icon);
  37. else
  38. curGroupMap.put("ICON",R.drawable.icon);
  39.  
  40. //Pop on the Name and Value
  41. curGroupMap.put("NAME",keyName);
  42. curGroupMap.put("VALUE",value);
  43. }
  44. }
  45.  
  46. curGroupMap = new HashMap<String,"By clicking here");
  47.  
  48. //Set up adapter
  49. mAdapter = new SimpleAdapter(
  50. mContext,groupData,R.layout.exp_list_parent,new String[] { "ICON","NAME","VALUE" },new int[] { R.id.photoAlbumImg,R.id.rowText1,R.id.rowText2 }
  51. );
  52.  
  53. myList.setAdapter(mAdapter); //Bind the adapter to the list
@H_502_4@在此先感谢您的帮助!!

解决方法

在这种情况下,您可以像其他任何视图一样将MapView添加到列表中. Here’s a quick tutorial关于如何创建自定义列表适配器.但是我必须提醒你,一个MapView是一个非常沉重的视图,如果你尝试在屏幕上收集一些它们,你会注意到应用程序迟钝!您可以添加一个按钮,将列表项添加到另一个页面,其中包含更多信息,包括地图.

猜你在找的Android相关文章