I'm using drag and drop , I'm making matching concept , drag image from left to right, when answer will correct , at there i want to draw a line from left to right , i use many things as like
public class Dragtesting extends Activity implements OnTouchListener{
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.drag);
ViewGroup dlayout = (ViewGroup)findViewById(R.id.dlayout);
dlayout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
// TODO Auto-generated method stub
if(touchFlag==true){
switch (paramMotionEvent.getActionMasked())
{
case MotionEvent.ACTION_DOWN :
//getting the positions
break;
case MotionEvent.ACTION_UP:
break;
Canvas canvas = new Canvas();
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setColor(Color.GREEN);
canvas.drawColor(Color.BLUE);
canvas.drawLine(offset_x, offset_y, currentX, currentY, paint);
break;
default:
break;
}
}
return true;
}
});
@Override
public boolean onTouch(View paramView, MotionEvent paramMotionEvent) {
// TODO Auto-generated method stub
switch (paramMotionEvent.getActionMasked())
{
case MotionEvent.ACTION_DOWN:
touchFlag=true;
offset_x = (int) paramMotionEvent.getX();
offset_y = (int) paramMotionEvent.getY();
// tagvalue = (Integer) paramView.getTag();
selected_item = paramView;
imageParams=paramView.getLayoutParams();
break;
case MotionEvent.ACTION_UP:
selected_item=null;
touchFlag=false;
break;
default:
break;
}
return false;
}
this is not working , help me