当前位置:  编程技术>移动开发
本页文章导读:
    ▪几何对象的作图        几何对象的绘制 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();

 

光标就出来了


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
Web服务器/前端 iis7站长之家
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3