你好,我想問一下,我怎麼能在圖像顯示吐司附近的用戶點擊點像下面使用GraphView庫:GraphView如何顯示吐司用戶點擊點附近
感謝您的任何意見
編輯:
我嘗試了用
seriesSin = new GraphViewSeries("Sinus curve", new GraphViewSeries.GraphViewSeriesStyle(Color.rgb(200, 50, 00), 3), data);
// SET ON TOUCH
graphView.setOnTouchListener(new View.OnTouchListener(){
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_DOWN) {
int size = seriesSin.size();
float screenX = event.getX();
float screenY = event.getY();
float width_x = v.getWidth();
float viewX = screenX - v.getLeft();
float viewY = screenY - v.getTop();
float percent_x = (viewX/width_x);
int pos = (int) (size*percent_x);
System.out.println("X: " + viewX + " Y: " + viewY +" Percent = " +percent_x);
System.out.println("YVal = " +seriesSin.getY(pos));
return true;
}
return false;
}
});
但我不能讓seriesSin.size和seriesSin.getY(POS)
棘手。你可以試一試'toast.setGravity(Gravity.TOP | Gravity.LEFT,x,y);'[touch of position](http://stackoverflow.com/a/23411401/1777090) – 2014-09-10 12:56:00
你好,感謝您的回覆,請參閱我的更新問題.. – redrom 2014-09-10 13:05:51
任何崩潰或只是獲得空值? – 2014-09-10 13:08:26