현재 1개의 액티비티와 1개의 클래스 자바파일이 있습니다.
액티비티는
private LinearLayout ParentContainer; CoordiContainer = new LinearLayout(this); CoordiContainer.setLayoutParams(new LayoutParams( CoordiContainer.setOrientation(LinearLayout.VERTICAL); TextView xCoordi = new TextView(this); DcoordiContainer = new LinearLayout(this); DcoordiContainer.setLayoutParams(new LayoutParams( DcoordiContainer.setOrientation(LinearLayout.VERTICAL); TextView xM = new TextView(this);
// ------------------------------------------------ canvasContainer.setLayoutParams(new LayoutParams( canvasContainer.setOrientation(LinearLayout.VERTICAL); TouchExampleView view = new TouchExampleView(this); // ------------------------------------------------ ButtonContainer.setLayoutParams(new LayoutParams( ButtonContainer.setOrientation(LinearLayout.HORIZONTAL); Button LeftClick = new Button(this); ButtonContainer.addView(LeftClick); Button RightClick = new Button(this); BottomContainer.setLayoutParams(new LayoutParams( BottomContainer.setOrientation(LinearLayout.HORIZONTAL); ParentContainer.setLayoutParams(new LayoutParams( ParentContainer.setOrientation(LinearLayout.VERTICAL);
|
이렇게 레이아웃만 만들어 놓은 상태이구요
다른 클래스는
public class TouchExampleView extends View { private float mLastTouchX; public TouchExampleView(Context context) { public TouchExampleView(Context context, AttributeSet attrs) { public TouchExampleView(Context context, AttributeSet attrs, int defStyle) { @Override canvas.save(); // -------------------------------------------------------------- final int action = ev.getAction(); // Remember where we started case MotionEvent.ACTION_MOVE: { // Move the object // Invalidate to request a redraw } |
이 icon의 좌표 mPosX와 mPosY의 좌표를
메인 액티비티의
CoordiContainer() 에서 출력해 줍니다.
그러면 onCreate()되며 액티비티가 처음 생성될 때만 저 변수의 값을 읽어오고 다음부터는 읽어오지 않습니다.
핸들러를 써서도 해봤지만 잘 안되네요 .
motion이벤트가 일어날때마다, mPosX,mPosY의 값이 갱신될 때마다 _touch 액티비티에서의 출력값을 갱신해주고싶은데
어떻게 하는 방법이 있을까요?
도와주세요 ㅠ_ㅠ