Android 列表视图中的MapvView v2
我正在尝试将MapView实现为ListView,但它无法正常工作。虽然显示了地图,但我无法以编程方式移动相机、添加任何标记对象,而且UI MyLocation按钮也不在那里。(我在适配器的getView方法中初始化了所有内容。我希望任何人都知道这个问题并能提供帮助。)感谢adavanceAndroid 列表视图中的MapvView v2,android,google-maps,listview,map,Android,Google Maps,Listview,Map,我正在尝试将MapView实现为ListView,但它无法正常工作。虽然显示了地图,但我无法以编程方式移动相机、添加任何标记对象,而且UI MyLocation按钮也不在那里。(我在适配器的getView方法中初始化了所有内容。我希望任何人都知道这个问题并能提供帮助。)感谢adavance @Override public View getView(int position, View convertView, ViewGroup parent) { View liste
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View listenEintrag = null;
if (position == 0) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listenEintrag = inflater.inflate(R.layout.details_head,
parent, false);
mMapView = (MapView) listenEintrag
.findViewById(R.id.mv_karteAnzeigen);
mMapView.onCreate(savedInstanceState);
MarkerOptions options = new MarkerOptions();
options.position(valueSpiel.getOrt().getPosition());
options.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
try {
initMapView();
mMapView.onResume();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}...
使用initMapView方法:
private void initMapView()
throws GooglePlayServicesNotAvailableException {
boolean usePlayService = isGooglePlayServiceAvailable();
if (usePlayService) {
MapsInitializer.initialize(getApplicationContext());
if (map == null) {
map = mMapView.getMap();
if (map != null) {
map.getUiSettings().setZoomControlsEnabled(true);
map.getUiSettings().setCompassEnabled(true);
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
map.animateCamera(CameraUpdateFactory.zoomTo(17.5f));
}
}
} else {
((Activity) getApplicationContext()).finish();
}
}
private boolean isGooglePlayServiceAvailable() {
int errorCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getApplicationContext());
if (errorCode != ConnectionResult.SUCCESS) {
Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
errorCode, (Activity) getApplicationContext(), -1);
if (errorDialog != null) {
errorDialog.show();
return false;
}
}
return true;
}
一般来说,这不是一个好主意,试着使用viewpager来托管地图。但是使用viewpager我无法创建列表,对吗?我以为它只是用于左右切换,例如基于für操作栏的选项卡?