Android : exiting a void method using an ontouch listener

on Sunday, February 1, 2015


in my app i have this structure method1 --> method2 --> listener


i want to exit method 2 using a condition i write in my listener



public void method1()
{
int a = 0;
gameOn(int a);
a++;
gameOn(int a);
}

public void method2()
{
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent e)
{
if(condition)
{
//do something
}else{
//exit method2 and continue method1
}
return true;
}
});
}


my original code is very dense so i summarized my goal..


the primary answer i found is using return but using return in the listener ends only itself..


0 comments:

Post a Comment