Kumar Anil
Kumar Anil

Reputation: 69

How to make hitTest, Collision Detection Functionality in Android

I have three small ImageView on Screen/View. OnTouch and onTouchMove I have to detect that the Touch/Mouse has collide the ImageView.

Upvotes: 0

Views: 1401

Answers (2)

DynamicMind
DynamicMind

Reputation: 4258

Use it for getting it.

@Override
public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
            int action=(int)event.getAction();
    return super.onTouchEvent(event);
}

event.getAction();
return three value.
0-MouseDown
1-MouseUp
2-MouseDrag

using this you can determine Touch/Mouse or collide.

Upvotes: 1

Snicolas
Snicolas

Reputation: 38168

imageView.setOnClickListener( new OnClickListener() {
     @Override
     public void onClick( View v )
     {
           System.out.println( "touched" );
     }//met
});

Upvotes: 0

Related Questions