android - How to listen for touch events on GraphView? -



android - How to listen for touch events on GraphView? -

i need add together behavior programme related user panning / zooming graphview. attempting register motion events notified of this, can user manipulating graph via touch.

i have tried overriding ontouchevent , implementing ontouchlistener in subclass of linegraph. have tried doing in fragment / view in putting graphview. however, methods never called, graph allows panning / zooming before.

e.g.:

public customlinegraphview(context context, string title) { super(context, title); this.setontouchlistener(this); } @override public boolean ontouchevent(motionevent event) { log.w("clg", "ontouchevent()"); homecoming true; } @override public boolean ontouch(view v, motionevent event) { log.w("clg", "ontouch()"); homecoming false; }

you need hook in underlying view graphview uses.

assuming have graphview object built named m_graphview, following. it's safest attach ontouchlistener every underlying child, incase implementation of graphview changes downwards road.

// attach ontouchlistener inner view receives touch events pan/zoom. int childcount = m_graphview.getchildcount(); for(int index = 0; index < childcount; index++) { m_graphview.getchildat(index).setontouchlistener(new graphtouchlistener()); }

be sure homecoming false in ontouch() baseclass behavior of pan/zoom still works.

private class graphtouchlistener implements view.ontouchlistener { @override public boolean ontouch(view v, motionevent event) { // whatever custom behavior want here // homecoming false base of operations ontouch event (pan, zoom) can still execute. homecoming false; } }

android android-graphview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -