public OnTouchCrossListener onTouchCrossListener;public interface OnTouchCrossListener {void onTouchCross(Object... data);}public void setOnTouchCrossListener(OnTouchCrossListener l) {this.onTouchCrossListener = l;}
@Overridepublic boolean onTouchEvent(MotionEvent event) {switch (event.getAction()) {case MotionEvent.ACTION_DOWN:case MotionEvent.ACTION_MOVE:x= event.getX();y = event.getY();- drawWave.onTouchCrossListener.onTouchCross(x,y);
case MotionEvent.ACTION_UP :mXCross = -1f;mCrossEnabled = false;// 重绘if(myThread!=null && myThread.myHandler != null) {myThread.myHandler.sendEmptyMessage(0);}break;}return true;}
mSurfaceView.setOnTouchCrossListener(new StockDrawWave.OnTouchCrossListener() {@Overridepublic void onTouchCross(Object... data) {// 此方法在StockDrawWave中子线程中被调用// 子线程不能直接更新当前主线程的UI。需要开启另外的线程,并利用handler发送消息到主线程final String xtime = (String)data[0];final float y = (float)data[1];App.post(new Runnable() {//@Overridepublic void run() {setTextViewFS(xtime, y, mYesterdayClosePrice);}});// Print.e("xtime,y",xtime + "," + y);}});
原文:http://www.cnblogs.com/chenchengzhi/p/4915220.html