当前位置: 编程技术>移动开发
本页文章导读:
▪几何对象的作图 几何对象的绘制
public class DrawGraphicElements extends Activity implements OnClickListener {
MapView mapView = null;
ArcGISTiledMapServiceLayer mTileMapLayer = null;
GraphicsLayer graphicsLayer = null;
MyTouchListener mTouchListener =.........
▪ 命令行中透过ant打包apk 命令行中通过ant打包apk
参考自:http://developer.android.com/guide/developing/building/building-cmdline.html
第一步:安装ant,从官网下载最新版ant并解压缩,配置ant环境变量,ant_home和path
第二步:在cmd下切换到项.........
▪ edittext光标定位到最右侧 edittext光标定位到最右边
private EditText nickname;
nickname = (EditText) findViewById(R.id.nickname);
nickname.setText(name);
Editable etext = nickname.getText();
nickname.setSelection(etext.length());
如果有时还是不能.........
[1]几何对象的作图
来源: 互联网 发布时间: 2014-02-18
几何对象的绘制
public class DrawGraphicElements extends Activity implements OnClickListener { MapView mapView = null; ArcGISTiledMapServiceLayer mTileMapLayer = null; GraphicsLayer graphicsLayer = null; MyTouchListener mTouchListener = null; Button geometryButton = null; Button clearButton = null; String mapURL = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyBasemap/MapServer"; final String[] geometryTypes = new String[] { "绘制点", "绘制线", "绘制区域" }; int selectedGeometryIndex = -1; @SuppressWarnings("serial") public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.map); mTouchListener = new MyTouchListener(DrawGraphicElements.this, mapView); mapView.setOnTouchListener(mTouchListener); geometryButton = (Button) findViewById(R.id.geometrybutton); geometryButton.setEnabled(false); geometryButton.setOnClickListener(this); clearButton = (Button) findViewById(R.id.clearbutton); clearButton.setOnClickListener(this); mTileMapLayer = new ArcGISTiledMapServiceLayer(mapURL); graphicsLayer = new GraphicsLayer(); mapView.addLayer(mTileMapLayer); mapView.addLayer(graphicsLayer);// 添加客户端要素图层 // 地图加载的时候被调用:检查地图是否可用 mTileMapLayer.setOnStatusChangedListener(new OnStatusChangedListener() { public void onStatusChanged(Object arg0, STATUS status) { if (status.equals(OnStatusChangedListener.STATUS.INITIALIZED)) { // 可用绘制按钮可用 geometryButton.setEnabled(true); } } }); } // 地图触摸事件 class MyTouchListener extends MapOnTouchListener { MultiPath mMutiPath;//多路径 String type = ""; Point startPoint = null; public MyTouchListener(Context context, MapView view) { super(context, view); } public void setType(String geometryType) { this.type = geometryType; } public String getType() { return this.type; } // 绘制一个点 public boolean onSingleTap(MotionEvent e) { if (type.length() > 1 && type.equalsIgnoreCase("POINT")) { graphicsLayer.removeAll();//清空要素图层 Point point = mapView.toMapPoint(new Point(e.getX(), e.getY())); // 注意:因手机分辨率的差异,像素点的大小是有差别的 SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol( Color.BLUE, 30, STYLE.CIRCLE); Graphic graphic = new Graphic(point, markerSymbol); graphicsLayer.addGraphic(graphic); clearButton.setEnabled(true); return true; } return false; } //绘制一个点并移动 public boolean onDragPointerMove(MotionEvent from, MotionEvent to) { if (type.length() > 1 && (type.equalsIgnoreCase("POLYLINE") || type .equalsIgnoreCase("POLYGON"))) { //终点 Point toPoint = mapView.toMapPoint(to.getX(), to.getY()); if (startPoint == null) { graphicsLayer.removeAll(); //绘制线还是绘制区域 mMutiPath = type.equalsIgnoreCase("POLYLINE") ? new Polyline(): new Polygon(); //记录开始点 startPoint = mapView.toMapPoint(from.getX(), from.getY()); mMutiPath.startPath((float) startPoint.getX(),(float) startPoint.getY()); SimpleLineSymbol lineSymbol=new SimpleLineSymbol(Color.BLUE,5); Graphic graphic = new Graphic(startPoint,lineSymbol); graphicsLayer.addGraphic(graphic); } mMutiPath.lineTo((float) toPoint.getX(), (float) toPoint.getY()); return true; } return super.onDragPointerMove(from, to); } //绘制一个点后抬起 @Override public boolean onDragPointerUp(MotionEvent from, MotionEvent to) { if (type.length() > 1 && (type.equalsIgnoreCase("POLYLINE") || type .equalsIgnoreCase("POLYGON"))) { if (type.equalsIgnoreCase("POLYGON")) { mMutiPath.lineTo((float) startPoint.getX(),(float) startPoint.getY()); graphicsLayer.removeAll(); //添加面 Graphic graphic=new Graphic(mMutiPath,new SimpleFillSymbol(Color.WHITE)); graphicsLayer.addGraphic(graphic); startPoint = null; clearButton.setEnabled(true); } else{ //添加线 Graphic graphic=new Graphic(mMutiPath,new SimpleLineSymbol(Color.BLUE, 5)); graphicsLayer.addGraphic(graphic); startPoint = null; clearButton.setEnabled(true); } return true; } return super.onDragPointerUp(from, to); } } // 对话框 protected Dialog onCreateDialog(int id) { return new AlertDialog.Builder(DrawGraphicElements.this).setTitle("绘制") .setItems(geometryTypes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { graphicsLayer.removeAll(); String geomType = geometryTypes[which]; selectedGeometryIndex = which; if (geomType.equalsIgnoreCase(geometryTypes[2])) { mTouchListener.setType("POLYGON"); } else if (geomType.equalsIgnoreCase(geometryTypes[1])) { mTouchListener.setType("POLYLINE"); } else if (geomType.equalsIgnoreCase(geometryTypes[0])) { mTouchListener.setType("POINT"); } } }).create(); } @Override protected void onPause() { super.onPause(); mapView.pause(); } @Override protected void onResume() { super.onResume(); mapView.unpause(); } @Override public void onClick(View v) { if (v == geometryButton) { showDialog(0); } else if (v == clearButton) { graphicsLayer.removeAll(); clearButton.setEnabled(false); } } }
[2] 命令行中透过ant打包apk
来源: 互联网 发布时间: 2014-02-18
命令行中通过ant打包apk
参考自:http://developer.android.com/guide/developing/building/building-cmdline.html
第一步:安装ant,从官网下载最新版ant并解压缩,配置ant环境变量,ant_home和path
第二步:在cmd下切换到项目根目录,执行以下命令: android update project -t 14 -p E:\other\AntTest(项目路径)
这个命令运行后会在项目根目录下生成build.xml文件
第三步:在cmd下执行ant debug命令会在项目的bin目录下生成使用debug签名的apk
第四步:若要生成自定义签名apk,则在项目根目录下添加ant.properties文件,配置密钥的路径和别名
key.store=路径
key.store.password=
key.alias=
key.alias.password=
在cmd下执行ant release会在bin目录下生成自定义签名apk,
[3] edittext光标定位到最右侧
来源: 互联网 发布时间: 2014-02-18
edittext光标定位到最右边
private EditText nickname; nickname = (EditText) findViewById(R.id.nickname); nickname.setText(name); Editable etext = nickname.getText(); nickname.setSelection(etext.length());
如果有时还是不能见到edittext的光标,再写一句:
nickname.requestFocus();
光标就出来了
最新技术文章: