Note that there are some explanatory texts on larger screens.

plurals
  1. POAchartEngine getScreenPosition to Display Toast near the user click point
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/g9U98.png" alt="enter image description here">hello I want to display a toast when user click on achartengine Point with display value . I am trying to get screen position value using toScreenPoint method but it will give wrong value if I pan a screen (move a chart) after that it give proper screen point and I set this Value to Toast. my code is shown below.</p> <pre><code> chart=new TimeChart(dataset, charthelper.getXYMultipleSeriesRenderer()); graphview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SeriesSelection ss=graphview.getCurrentSeriesAndPoint(); if (ss == null) { } else { double[] screenPoint = chart.toScreenPoint(new double[] { ss.getXValue(),ss.getValue() },0); toast_textview.setText(ss.getValue()+""); Toast toast=new Toast(getApplicationContext()); toast.setGravity(Gravity.TOP|Gravity.LEFT, (int)screenPoint[0],(int)screenPoint[1]); toast.setView(toast_layout); toast.show(); } } }); container_layout.addView(graphview,0); </code></pre> <p><strong>[UPDATE]</strong> i solved it using this way </p> <pre><code> /** * set ontouch listener for double tap */ graphview.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { x = event.getX(); y = event.getY(); detector.onTouchEvent(event); detector.setIsLongpressEnabled(true); return false; } }); graphview.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SeriesSelection ss = graphview.getCurrentSeriesAndPoint(); if (ss == null) { } else { /** * toast display only series of value which index is * zero */ if (ss.getSeriesIndex() == 0) { toast_textview.setText(ss.getValue() + ""); Toast toast = new Toast(getApplicationContext()); DecimalFormat formatter = new DecimalFormat("##.##"); toast_textview.setText(formatter.format(ss.getValue()) + ""); toast.setGravity(Gravity.TOP | Gravity.LEFT, (int) x, (int) y); toast.setView(toast_layout); toast.setDuration(Toast.LENGTH_SHORT); toast.show(); } } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload