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

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -