Question

For my app is not really usefull the fitZoom button of the graph but that space would be great for displaying a contextual menu with some graph info. I have already changed the image of the button and everything, but I don't know how I can change the button functionality as the contextual menu would be related to the activity and not to the graph.

I don't know if I explained it good, may be a bit messy, but tell me which part is not clear enough!

Any Ideas?

Thnank you very much!

Was it helpful?

Solution

I solved it myself, in a very ugly way but it works!

First you have to disactivate the zoomFit onClick action and after I did the next:

I added into GraphicalView in achartengine library this function that tells me when the fit button has been pressed:

    public boolean isCompare(MotionEvent event) {
    int action = event.getAction();
    RectF zoomR = new RectF();
    zoomR =  getZoomRectangle();;
    boolean comp = false;
    if (action == MotionEvent.ACTION_DOWN) {
        oldX = event.getX(0);
        oldY = event.getY(0);
        if (mRenderer != null && mRenderer.isZoomEnabled()
                && mZoomR.contains(oldX, oldY)) {
            if (oldX < mZoomR.left + mZoomR.width() / 3) {
                comp = false;
            } else if (oldX < mZoomR.left + mZoomR.width() * 2 / 3) {
                comp = false;
            } else {
                comp= true;
            }
                // graphicalView.zoomReset();
            }
        }
    return comp;
}

Ans I added the onTouchListener to my Activity:

    public void setChartListener(final GraphicalView view){
    view.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub

            view.onTouchEvent(event);
            boolean is = view.isCompare(event);
            if (is) {
                //Action to do when pressed
            } else {
                                    //null
            }
            return is;
        }
    });
}

If someone knows better way...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top