当我点击一个点时,我想在弹出窗口中显示文件和属性。但我得到Null Pointer Exception。为什么我回到我身边?你能帮帮忙吗?我能怎么做?我确实喜欢esri android示例。但它不起作用。
/// long press to map
mapView.setOnLongPressListener(new OnLongPressListener() {
private static final long serialVersionUID = 1L;
// ArcGISFeatureLayer
private ArcGISFeatureLayer featureLay = null;
/// override onLongPress
@Override
public boolean onLongPress(final float v, final float v1) {
if (mapView.isLoaded()) {
if (progressDialog != null && progressDialog.isShowing()
&& count.intValue() == 0)
//dismiss dialog
progressDialog.dismiss();
// Get the point featurelayer
Layer[] layers = mapView.getLayers();
for (Layer layer : layers) {
if (layer instanceof ArcGISFeatureLayer) {
ArcGISFeatureLayer fl = (ArcGISFeatureLayer) layer;
if (fl.getGeometryType() == Geometry.Type.POINT) {
featureLay = fl;
break;
}
}
}
//// if featureLay null
if (featureLay == null)
return false;
ArcGISPopupInfo popupInfos = (ArcGISPopupInfo) featureLay.getPopupInfos();
///!!!!!!!!!!!!!!! return to me null////////////
if (popupInfos == null)
return false;
// Create a new feature
Point point = mapView.toMapPoint(v, v1);
Feature feature2;
FeatureType[] types = featureLay.getTypes();
if (types == null || types.length < 1) {
FeatureTemplate[] templates = featureLay
.getTemplates();
if (templates == null || templates.length < 1) {
feature2 = new Graphic(point, null);
} else {
feature2 = featureLay.createFeatureWithTemplate(
templates[0], point);
}
} else {
feature2 = featureLay.createFeatureWithType(
featureLay.getTypes()[0], point);
}
// Instantiate a PopupContainer
popupContainer = new PopupContainer(mapView);
// popup create
Popup popupp = featureLay.createPopup(mapView, 0, feature2);
popupContainer.addPopup(popupp);
popupp.setEditMode(true);
createEditorBar(featureLay, false);
// Create a dialog for the popups and display it.
popupDialog = new PopupDialog(mapView.getContext(),
popupContainer);
// show popup
popupDialog.show();
}
return true;
}
});