gesture - Android: why does a swipe kill my app? -


i trying make textview change when swipe across screen. used gesturedector.ongesturelistener, , recoded onfling() methode follows:

@override public boolean onfling(motionevent motionevent, motionevent motionevent2, float v, float v2) {     if (motionevent.getrawy() < motionevent2.getrawy()) {         ((textview) findviewbyid(r.id.textview)).settext("next");     } else if (movetasktoback(motionevent.getrawy() > motionevent2.getrawy())) {         ((textview) findviewbyid(r.id.textview)).settext("previous");     }      return true; } 

but in case, weird reason, when flick left app stops (like pressed home button).

what causing this?

edit: if reopen app , press return button (physical), show "previous", therefore can conclude swipe works happening after setting textview culprit.

findviewbyid(r.id.textview) 

this throw error if textview r.id.textview not on current content view.

sometimes, overrides, need this:

return super.onfling(motionevent, motionevent2, v, v2); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -