编译androidplot时出错

编译androidplot时出错,android,plot,androidplot,Android,Plot,Androidplot,我正在尝试使用android plot库,只需复制示例页面的代码即可 我添加了librery源代码,只是在示例代码中更改了以下行,因为它给了我一个错误: // Create a formatter to use for drawing a series using LineAndPointRenderer // and configure it from xml: LineAndPointFormatter series1Format = new LineAndPointFor

我正在尝试使用android plot库,只需复制示例页面的代码即可

我添加了librery源代码,只是在示例代码中更改了以下行,因为它给了我一个错误:

// Create a formatter to use for drawing a series using LineAndPointRenderer
    // and configure it from xml:
    LineAndPointFormatter series1Format = new LineAndPointFormatter();
    series1Format.setPointLabelFormatter(new PointLabelFormatter());
    series1Format.configure(getApplicationContext(),
            R.xml.line_point_formatter_with_plf1);
我将最后一行更改为:

R.layout.line_point_formatter_with_plf1);
该程序需要几分钟来编译,并且会出现如下错误

Android Dex:[prueba graficos](org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler$1)没有附带

Android索引:[prueba graficos]关联的封闭方法属性。这个类可能是由一个

Android Dex:[prueba graficos]并且不指定任何“-target”类型选项。忽视的后果

我对样式也有一个错误,在示例中,样式为style=“@style/sample\u activity”,但我没有该样式,所以我只设置布局大小

在layout/xml/line\u point\u formatter\u中使用_plf1.xml

<?xml version="1.0" encoding="utf-8"?>
<config
    linePaint.strokeWidth="3dp"
    linePaint.color="#00AA00"
    vertexPaint.color="#007700"
    fillPaint.color="#00000000"
    pointLabelFormatter.textPaint.color="#FFFFFF"/>


“配置算法”一词给了我一个错误:应该定义“布局高度”属性。

实际上,您提供的教程中有一个小错误: 文件行_point _formatter _plf1.xml和行_point _formatter _plf2.xml应位于文件夹res/xml/下。如果res/文件夹下没有xml文件夹,只需创建它,它将毫无问题地接受配置标记

这是因为您将它们放在layout/下,它会将它们视为布局文件,并告诉您,对于布局xml文件,“config”标记作为根是不可接受的

对于“应定义布局高度”属性错误,只需添加以下两行:

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
指向simple_xy_plot_example.xml文件的根标记(此错误与config标记无关)

简单的_xy_plot_example.xml文件应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              style="@style/AppTheme"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent">

    <com.androidplot.xy.XYPlot
            android:id="@+id/mySimpleXYPlot"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            androidPlot.title="A Simple XY Plot"
            androidPlot.domainLabel="Domain"
            androidPlot.rangeLabel="Range"
            androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
            androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
            androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
            androidPlot.graphWidget.marginTop="20dp"
            androidPlot.graphWidget.marginLeft="15dp"
            androidPlot.graphWidget.marginBottom="25dp"
            androidPlot.graphWidget.marginRight="10dp"
            androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
            androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
            androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
            androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
            androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
            androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
            androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
            androidPlot.legendWidget.heightMetric.value="25dp"
            androidPlot.legendWidget.positionMetrics.anchor="right_bottom"
            androidPlot.graphWidget.gridLinePaint.color="#000000"/>
</LinearLayout>


我试过了,效果很好

实际上,您提供的教程中有一个小错误: 文件行_point _formatter _plf1.xml和行_point _formatter _plf2.xml应位于文件夹res/xml/下。如果res/文件夹下没有xml文件夹,只需创建它,它将毫无问题地接受配置标记

这是因为您将它们放在layout/下,它会将它们视为布局文件,并告诉您,对于布局xml文件,“config”标记作为根是不可接受的

对于“应定义布局高度”属性错误,只需添加以下两行:

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
指向simple_xy_plot_example.xml文件的根标记(此错误与config标记无关)

简单的_xy_plot_example.xml文件应如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              style="@style/AppTheme"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent">

    <com.androidplot.xy.XYPlot
            android:id="@+id/mySimpleXYPlot"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            androidPlot.title="A Simple XY Plot"
            androidPlot.domainLabel="Domain"
            androidPlot.rangeLabel="Range"
            androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
            androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
            androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
            androidPlot.graphWidget.marginTop="20dp"
            androidPlot.graphWidget.marginLeft="15dp"
            androidPlot.graphWidget.marginBottom="25dp"
            androidPlot.graphWidget.marginRight="10dp"
            androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
            androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
            androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
            androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
            androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
            androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
            androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
            androidPlot.legendWidget.heightMetric.value="25dp"
            androidPlot.legendWidget.positionMetrics.anchor="right_bottom"
            androidPlot.graphWidget.gridLinePaint.color="#000000"/>
</LinearLayout>


我试过了,效果很好

感谢您的帮助,我尝试了您所说的方法,解决了一些问题,但编译仍然失败,样式部分给了我一个错误,所以我删除了这一行,其余的与您所说的相同,以下是一些错误:Android Dex:[prueba graficos](org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler$1)这并没有附带Android Dex:[prueba-graficos]意外的顶级异常:Android Dex:[prueba-graficos]无法在com.Android.DX.Dex.cf.CfTranslator.translate0(CfTranslator.java:134)上执行DX Android Dex:[prueba-graficos],对于样式,请改为:style=“@style/AppTheme”(请投票支持我的答案,如果它确实对你有帮助,请将其标记为正确答案)如果AppTheme不起作用,请转到res/values/下的文件styles.xml并检查样式标记的name属性谢谢您的帮助,我尝试了您所说的方法,解决了一些问题,但编译仍然失败,样式部分给了我一个错误,所以我删除了该行,其余的与您所说的相同,下面是一些错误:Android Dex:[prueba-graficos](org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler$1)没有附带Android Dex:[prueba-graficos]意外的顶级异常:Android Dex:[prueba-graficos]无法在com.Android.DX.Dex.cf.CfTranslator.translate0(CfTranslator.java:134)上执行DX Android Dex:[prueba-graficos]对于样式,请改为:style=“@style/AppTheme”(请向上投票我的答案,或者如果它对您有帮助,请将其标记为正确答案)。如果AppTheme不起作用,请转到res/values/下的文件styles.xml,并检查样式标记的name属性