按imoble 9D的帮助文档进行操作,发现错误R cannot be resolved to a variable ,添加引用只有import yrxcom.example.supermapimobiledemo.R可以解决,但安装的时候显示包不存在,安装App后闪退;其他import android.support.v7.appcompat.R还有import com.supermap.mapping.R等包都会将问题移到后面的activity_main、zoomControls等等让创建变量或常量。有办法解决吗
package com.example.supermapimobiledemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ZoomControls;
import com.supermap.data.Environment;
import com.supermap.data.Workspace;
import com.supermap.data.WorkspaceConnectionInfo;
import com.supermap.data.WorkspaceType;
import com.supermap.mapping.MapControl;
import com.supermap.mapping.MapView;
public class MainActivity extends Activity {
private MapControl m_mapControl = null;
private Workspace m_wokspace;
private MapView m_mapView;
private ZoomControls m_zoom;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//设置一些系统需要用到的路径
String rootPath =
android.os.Environment.getExternalStorageDirectory().getAbsolutePath();
Environment.setLicensePath(rootPath + "/SuperMap/license/");
Environment.setTemporaryPath(rootPath + "/SuperMap/temp/");
Environment.setWebCacheDirectory(rootPath + "/SuperMap/WebCache/");
// 组件功能必须在Environment初始化之后才能调用
Environment.initialization(this);
setContentView(R.layout.activity_main);
// 打开工作空间
m_wokspace = new Workspace();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo();
info.setServer(rootPath + "/SuperMap/SampleData/GeometryInfo/World.smwu");
info.setType(WorkspaceType.SMWU);
m_wokspace.open(info);
//将地图显示控件和工作空间关联
//打开工作空间中的第二幅地图
String mapName = m_wokspace.getMaps().get(1);
m_mapControl.getMap().open(mapName);
m_zoom = (ZoomControls)findViewById(R.id.zoomControls);
m_mapView = (MapView)findViewById(R.id.Map_view);
m_zoom.setIsZoomInEnabled(true);
m_zoom.setIsZoomOutEnabled(true);
// 放大按钮
m_zoom.setOnZoomInClickListener(new OnClickListener(){
public void onClick(View v) {
m_mapControl.getMap().zoom(2);
m_mapControl.getMap().refresh();
}
});
// 缩小按钮
m_zoom.setOnZoomOutClickListener(new OnClickListener(){
public void onClick(View v) {
m_mapControl.getMap().zoom(0.5);
m_mapControl.getMap().refresh();
}
});
m_mapControl.getMap().refresh();
}
}
//注意:组件功能必须在Environment初始化之后才能调用