isuru isuru -4 years ago 227
Android Question

Cannot resolve method contains(int, int)?

I'm trying to check particular region contains touch points on

in Android. Initially I put my all the regions data in array as follows.

ArrayList<Region> regionlist = new ArrayList<>();

RectF rectF = new RectF();
path.computeBounds(rectF, true);
r = new Region();
r.setPath(path, new Region((int) rectF.left, (int), (int) rectF.right, (int) rectF.bottom));

Here is my

public boolean onTouchEvent(MotionEvent event) {

Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();
Log.d(TAG, "point: " + point);

for( Object result : regionlist ) {
Log.d("isuru", "Bucha " + result);
if(result.contains(point.x, point.y)) { //Error Line
Log.d(TAG, "Touch IN");
}else {
Log.d(TAG, "Touch OUT");

return true;


As I mention in my code
shows error as
Cannot resolve method contains(int, int)
? Why this happens?

Answer Source

Please change the following code

for( Object result : regionlist ) {


for( Region result : regionlist ) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download