• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to Drag a textView?

jeponkz

Lurker
hey guys I have problem dragging textView. see the codes.

Code:
ball = (TextView) findViewById(R.id.textView1);
        OnTouchListener onThumbTouch = new OnTouchListener()
        {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				switch(event.getAction())
	            {
	                        case MotionEvent.ACTION_DOWN:
	                        {                          
	                			touchOffsetX = event.getX();
	                			touchOffsetY = event.getY();
	                        }
	                        case MotionEvent.ACTION_UP:
	                        {                           

	                        }
	                    break;
	               
	            }
				return true;
			}
        };
        ball.setOnTouchListener(onThumbTouch);

the code is not working, is there any way I that I can make it work?
 
Well, I mean you are just changing the values touchOffsetX and touchOffsetY variables in the code you show. You need to use those variables to set the TextView's position and then invalidate it.
 
Back
Top Bottom