- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试为我的随机生成器创建一个动态图表,以保持抽取值。对于我使用的图表 AChartEngine .我很清楚我的方法是使用异步任务机制通过动态图表的后台线程进行更新。但我无法使用 AChartEngine 库获得基本的 XY 图表。应用程序每次都会崩溃。这是我的基本 XY 图表代码。
package com.example.graph2;
import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class Graph2Activity extends Activity {
private XYMultipleSeriesDataset RNG_Dataset = new XYMultipleSeriesDataset();
private XYMultipleSeriesRenderer RNG_Renderer = new XYMultipleSeriesRenderer();
public XYSeries RNG_CurrentSeries;
private GraphicalView RNG_ChartView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RNG_Renderer.setAxisTitleTextSize(16);
RNG_Renderer.setChartTitleTextSize(20);
RNG_Renderer.setLabelsTextSize(15);
RNG_Renderer.setLegendTextSize(15);
RNG_Renderer.setMargins(new int[] {20, 30, 15, 0});
RNG_Renderer.setAxesColor(Color.YELLOW);
String seriesTitle = "RNG";
XYSeries series = new XYSeries(seriesTitle);
RNG_Dataset.addSeries(series);
RNG_CurrentSeries = series;
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setColor(Color.RED);
RNG_Renderer.addSeriesRenderer(renderer);
setContentView(R.id.RNGchart);
}
protected void onResume() {
if (RNG_ChartView == null) {
LinearLayout layout = (LinearLayout) findViewById(R.id.RNGchart);
RNG_ChartView = ChartFactory.getLineChartView(this, RNG_Dataset, RNG_Renderer);
layout.addView(RNG_ChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
// boolean enabled = HRDataset.getSeriesCount() > 0;
// setSeriesEnabled(enabled);
} else {
RNG_ChartView.repaint();
}
}
}
这是我使用的 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RNGchart" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="300px"
android:layout_weight="1" />
有人可以告诉我哪里出错了吗?这是异常日志:
10-10 17:20:52.761: ERROR/AndroidRuntime(335): FATAL EXCEPTION: main
10-10 17:20:52.761: ERROR/AndroidRuntime(335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.graph2/com.example.graph2.Graph2Activity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f050000 type #0x12 is not valid
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.os.Looper.loop(Looper.java:123)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invokeNative(Native Method)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at java.lang.reflect.Method.invoke(Method.java:507)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at dalvik.system.NativeStart.main(Native Method)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f050000 type #0x12 is not valid
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1874)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.content.res.Resources.getLayout(Resources.java:731)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.Activity.setContentView(Activity.java:1657)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at com.example.graph2.Graph2Activity.onCreate(Graph2Activity.java:44)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-10 17:20:52.761: ERROR/AndroidRuntime(335): ... 11 more
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.graph2"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Graph2Activity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="org.achartengine.chartdemo.demo.chart.XYChartBuilder" />
<activity android:name="org.achartengine.GraphicalActivity" />
<activity android:name=".GeneratedChartDemo" />
</application>
</manifest>
最佳答案
您可以从 here 查看我的完整Demo
试试这个,
<activity android:name="com.example.graph2.Graph2Activity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
并确保您的 Graph2Activity Activity 位于 com.example.graph2 包内。
关于android - 随机生成器的 XY 图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7711986/
我正在尝试使用 (X,Y) 形式的 XY 点数组中的三个 XY 点找到最大面积。 我目前收到错误 called object type 'double' is not a function or fu
我在屏幕上设定的 XY 位置(例如 x=100,y=200)有一个点 (A),在屏幕上随机的 XY 位置(例如 x=50)有另一个点 (B) , y = 50)。 我想沿直线将点 B 移向点 A。 如
在我的项目中,每次打开 JSP 时我都必须分配一个变量。我用小脚本试过了 在 JSP 和 EL 中 ${}返回变量。 但是好像不行。 korrekteAntwort=${}后出现错误, 难道不
这个问题在这里已经有了答案: Bind and Destructure block arguments (3 个答案) 关闭 4 年前。 鉴于以下内容目前在 Ruby 中的工作方式类似于 Haske
#include int main(double x, double y, double x1, double y1, double x2, double y2) { // First co
我有一个函数可以根据任意数量的字典(每个字典代表图表上的一条线)生成 XY 散点图,每个字典都包含一个日期键和一个数值。到目前为止,这些值似乎在 Y 轴上有效,但日期轴 (X) 似乎已损坏。每次我从字
尝试绘制一个 xy 散点图,其中 z 值由 xy 点的颜色表示。 数据: 1.1, 32.27, 19.4 1.2, 21.34, 18 1.4, 47.45, 19.4 R代码: inp <-
我有以下代码: var favourites = JSON.parse(localStorage.getItem("favourites")); Service.all().then(function
我确实在对齐 rec 标签中的文本时遇到问题。遵循代码和两张描述案例的图片。 HTML: DACH 我确实想将文本左对齐到 rect-tag 的开头。附件是来自 Debug模式的图片,
我在 MATLAB 中有一个 x-y 散点图,想在每个点上放置一个数据标签。我似乎无法在文档中找到它。可能吗? 最佳答案 例子: p = rand(10,2); scatter(p(:,1), p(:
本文整理了Java中com.androidplot.xy.YValueMarker类的一些代码示例,展示了YValueMarker类的具体用法。这些代码示例主要来源于Github/Stackoverf
本文整理了Java中com.androidplot.xy.ZoomEstimator类的一些代码示例,展示了ZoomEstimator类的具体用法。这些代码示例主要来源于Github/Stackove
我花了很多时间寻找它,但找不到。如果这是一个基本问题,请不要轰炸我:) 我想用以下向量生成散点图 > x [1] "a" "b" "c" "d" > y [1] 5 6 3 4 我使用了 xyplot
这似乎微不足道 R问题,但我没有找到任何令人信服的解决方案。我想翻转 X 轴变为 Y 的图,反之亦然。在箱线图中有一个 horiz="T"选项,但不在 plot() 中. 这是我的情节: plot(r
This问题解释了如何在特定位置添加网格 点阵图(即相当于 两个 abline() 用于正常绘图)。我的问题是当 我尝试添加一个常规网格(相当于调用 grid() 对于正常情节)......情节的内容
我正在寻找创建 xy 图的 GWT api/示例。这是我在 powerpoint 中制作的示例图片。将有另外两个图,如下例所示,每个点都可以点击,然后在另一个图上突出显示。有没有办法在 GWT 中使用
我想将两个时间序列图表放置在彼此之上共享相同的时域轴,都具有多个数据集。 chart1 = ChartFactory.createTimeSeriesChart("", "", "", tsc1, t
我绘制了以下内容: t = data.frame(Sample=c('1','1','1','2','2','2'), X=c(12,13,14,12,11,15), Y=c(4,3,5,1,2,3)
我有一个 CAD 应用程序,我正在尝试为其构建插件,并且我需要能够选择直线和圆弧。我不能直接从应用程序中执行此操作。在我的代码中,我想开始用鼠标徒手绘制一个窗口矩形。通过 API,我可以确定刚刚绘制的
我想将 2 个变量的函数值显示为“位图”图像,例如 x+y。所以我尝试了这个,基于 http://gnuplot.sourceforge.net/demo/heatmaps.html : # Colo
我是一名优秀的程序员,十分优秀!