Android的 - 包含在一个列表视图中的图形页面 [英] Android - MapView contained within a Listview
问题描述
目前我试图把一个ListView内的图形页面。有没有人有任何与此成功呢?它甚至有可能?这是我的code:
Currently I am trying to place a MapView within a ListView. Has anyone had any success with this? Is it even possible? Here is my code:
ListView myList = (ListView) findViewById(android.R.id.list);
List<Map<String, Object>> groupData = new ArrayList<Map<String, Object>>();
Map<String, Object> curGroupMap = new HashMap<String, Object>();
groupData.add(curGroupMap);
curGroupMap.put("ICON", R.drawable.back_icon);
curGroupMap.put("NAME","Go Back");
curGroupMap.put("VALUE","By clicking here");
Iterator it = data.entrySet().iterator();
while (it.hasNext())
{
//Get the key name and value for it
Map.Entry pair = (Map.Entry)it.next();
String keyName = (String) pair.getKey();
String value = pair.getValue().toString();
if (value != null)
{
//Add the parents -- aka main categories
curGroupMap = new HashMap<String, Object>();
groupData.add(curGroupMap);
//Push the correct Icon
if (keyName.equalsIgnoreCase("Phone"))
curGroupMap.put("ICON", R.drawable.phone_icon);
else if (keyName.equalsIgnoreCase("Housing"))
curGroupMap.put("ICON", R.drawable.house_icon);
else if (keyName.equalsIgnoreCase("Website"))
curGroupMap.put("ICON", R.drawable.web_icon);
else if (keyName.equalsIgnoreCase("Area Snapshot"))
curGroupMap.put("ICON", R.drawable.camera_icon);
else if (keyName.equalsIgnoreCase("Overview"))
curGroupMap.put("ICON", R.drawable.overview_icon);
else if (keyName.equalsIgnoreCase("Location"))
curGroupMap.put("ICON", R.drawable.map_icon);
else
curGroupMap.put("ICON", R.drawable.icon);
//Pop on the Name and Value
curGroupMap.put("NAME", keyName);
curGroupMap.put("VALUE", value);
}
}
curGroupMap = new HashMap<String, Object>();
groupData.add(curGroupMap);
curGroupMap.put("ICON", R.drawable.back_icon);
curGroupMap.put("NAME","Go Back");
curGroupMap.put("VALUE","By clicking here");
//Set up adapter
mAdapter = new SimpleAdapter(
mContext,
groupData,
R.layout.exp_list_parent,
new String[] { "ICON", "NAME", "VALUE" },
new int[] { R.id.photoAlbumImg, R.id.rowText1, R.id.rowText2 }
);
myList.setAdapter(mAdapter); //Bind the adapter to the list
在此先感谢您的帮助!
Thanks in advance for your help!!
推荐答案
在这种情况下,你会的MapView添加到列表中即可,就像任何其他的看法。 这里有一个关于如何创建自定义的快速教程列表适配器。但我要提醒你,一个图形页面是pretty的重观,如果你试图让一群人的屏幕上你会发现应用程序呆滞!你可能只是一个按钮添加到列表中的项目,是以用户到另一页面的详细信息,包括地图。
In that case you would add the MapView to the list just like you would any other view. Here's a quick tutorial on how to create a custom list adapter. But I have to caution you, a MapView is a pretty heavy view and if you try to get a bunch of them on the screen you're going to notice the app being sluggish! You may just add a button to the list item that takes the user to another page with more information including a map.
这篇关于Android的 - 包含在一个列表视图中的图形页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!