- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在 android.support.v4.view.ViewPager
中有一个 achartengine GraphicalView 图表。
我希望我的图表在用户将手指拖到图表上时平移,但现在事件在一个小的拖动 Action 后被 ViewPager 捕获。
我希望能够让用户平移到图表的末尾,然后让 ViewPager 切换页面。作为替代方案,我想至少阻止 ViewPager 捕获图表内的拖动运动。
有什么想法吗?
最佳答案
这是我的解决方案。
它允许用户在图表中有数据时四处拖动图表。之后,拖动事件被 ViewPager 捕获。
就像我说的,关键是这个解决方案是 requestDisallowInterceptTouchEvent功能。
public class ParameterGraphicalView extends org.achartengine.GraphicalView {
// stores the data model size
private int mDataSize = 0;
// stores the first X position in the dataset
private long mDataStartX = 0;
// stores the last X position in the dataset
private long mDataEndX = 0;
// the ViewPager
private ViewParent mViewPager;
//(...)
@Override
public boolean onTouchEvent(MotionEvent event) {
// save the position of the first touch so we can determine whether the user is dragging
// left or right
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mFirstTouchX = event.getX();
}
// when mViewPager.requestDisallowInterceptTouchEvent(true), the viewpager does not
// intercept the events, and the drag events (pan, pinch) are caught by the GraphicalView
// we want to keep the ViewPager from intercepting the event if:
// 1- there are 2 or more touches, i.e. the pinch gesture
// 2- the user is dragging to the left but there is no data to show to the right
// 3- the user is dragging to the right but there is no data to show to the left
if (event.getPointerCount() > 1
|| (event.getX() < mFirstTouchX && mDataSize > 0 && mRenderer.getXAxisMax() < mDataEndX)
|| (event.getX() > mFirstTouchX && mData.size() > 0 && mRenderer.getXAxisMin() > mDataStartX)) {
mViewPager.requestDisallowInterceptTouchEvent(true);
}
else {
mViewPager.requestDisallowInterceptTouchEvent(false);
}
return super.onTouchEvent(event);
}
}
关于android - 在 viewpager 内平移的 achartengine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19359516/
我希望在我触摸图表区域的位置显示一个垂直光标。与此行关联的 textview 将显示条的值,即其中点的 y 轴值。当我将手指移到右边的左边同时保持我的手指向下 [向左移动或向右移动] 时,这个垂直光标
我正在为 Android 使用 aChartEngine 的 0.7.0 图表库。我有一个工作 XY 图表,当收到新数据时,它每秒动态变化。但是,它从左到右绘制折线图并最终移出 View 。查看正在绘
我的应用程序需要图形库,而我正在使用 achartengine 图形库。我的应用程序要求图形仅占屏幕的 50%,其他部分用于显示其他一些信息。 achartengine 的图形 API 是否可以有 x
我目前通过将 XYSeriesRenderer 颜色设置为白色来模拟此功能: final XYSeriesRenderer goodEventSeriesRenderer = new XYSe
我注意到我的时间图表的Xlabel与X- 值(value)观。这些点应在标签正上方。在左手边 可以,但是会向右移动。我不知道该怎么解决 我得到什么: http://tinypic.com/r/2uqj
我已使用默认渲染器尝试了以下操作 CategorySeries series = new CategorySeries("First test"); int numSlide = portions.l
我需要实现一个条形图,当用户触摸图表以垂直移动它时,它会读取值。图形向上移动,根据轴 记录值。以 x 轴为值,Y 轴为变量,我需要执行计算。理解示例 最佳答案 看看this例子。您还可以执行 mCha
我正在通过 achartengine 使用圆环图,它工作正常,但我不知道如何获取与用户单击的区域关联的值。通过阅读其他问题,我了解到这是可能的,但发布的修复程序对我不起作用。我尝试过使用 getCur
我在线性布局中使用 AChartEngine 绘制图表。 我在设置圆环图边距时遇到问题。我正在使用以下语句,但边距或中心没有改变。图表根据布局尺寸自动调整大小。有人可以帮忙吗? mRenderer.s
我正在尝试使用 aChartEngine 将 GPS 数据(正在查看或正在使用的卫星)显示为条形图,但我没有在此 View 中显示任何数据。这是我的代码,所以你能告诉我我犯了什么错误吗? public
我正在使用适用于 Android 的 AChartEngine 库,在时间图表中,x 标签与图表上的点不对应,正如您在图像中看到的那样。 看起来图表略微向右移动。有什么提示吗? 最佳答案 这可以用这个
如何在AChartEngine条形图中画笔画? 这对我不起作用: mCurrentSeries = new XYSeries("Sample Data"); mDataset.addSeries(mC
我的图表中有一个 sin 函数,用户可以在上面选择点。但是,当渲染器中唯一的 PointStyle 是 POINT 时,缩放颜色的背景是白色/透明的(不确定,因为我的背景是白色的)。但是,当我添加 P
我想使用 aChartEngine 在我的圆环图中添加可点击区域,但这还没有实现。我想我有办法实现它,所以我正在计划我需要的部分。我不确定的一部分是如何获得图表中心的孔的大小。具体来说,我需要知道内半
这是图表上显示任何最大值的方式。如何确保显示完整点? 最佳答案 手动设置Y轴最大可见值: renderer.setYAxisMax(10.5); 关于android - AChartEngine 只显
我用aChartEngine 创建了一个条形图。我遇到的问题是,为每个值(包括 0)创建条形。这意味着在值为 0 的地方,它会在相邻条形之间创建一个空间。 我想摆脱那个空间 - 我认为唯一的方法是在它
我在我的图 TableView 中的 TimeSeries 中添加了以下 4 个日期。 2-Jan-2013 3-Jan-2013 4-Jan-2013 7-Jan-2013 当我在模拟器中看到结果时
有什么方法可以在折线图中添加目标线? 我想绘制条形图中显示的绿线。 提前致谢。 最佳答案 我找到了答案。 我们可以使用 combinechart 来获取目标线。 // Specifying chart
我在我的 Android 应用程序中使用了 achartengine,并且能够绘制一些折线图。现在我需要绘制某种阈值线,它基本上是一条额外的红色线,它将在图表中的某个 Y 值处运行。 我阅读了有关阈值
在我的应用程序中,我切换了两个不同图表的 View 。第一次绘制的图形看起来很完美,但是当我转到另一个图形并返回时,看起来它绘制了同一个图形的两次,但大小不同,一旦您单击图形,它就会改变并看起来很完美
我是一名优秀的程序员,十分优秀!