0

我在 XYPlot.java 类中的粗线处出现错误。

XYPlot.java:

package com.arise.plotme;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.series.XYSeries;
import com.androidplot.xy.*;
import com.arise.plotme.R;

import java.util.Arrays;

/**
 * The simplest possible example of using AndroidPlot to plot some data.
 */
public class XYPlot extends Activity
{

    private XYPlot mySimpleXYPlot;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.plot_xml);



        // initialize our XYPlot reference:
        **mySimpleXYPlot = (XYPlot) findViewById(R.id.mySimpleXYPlot);**

        // Create a couple arrays of y-values to plot:
        Number[] series1Numbers = {12,2,4,3};// --x -lat
      //  Number[] series2Numbers = {1,2,10,3};
        Number[] series3Numbers = {2,12,-2,7};// --y -lon
        // Turn the above arrays into XYSeries':
        XYSeries series1 = new SimpleXYSeries(
                Arrays.asList(series1Numbers),     // --x    // SimpleXYSeries takes a List so turn our array into a List
             //SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
                Arrays.asList(series3Numbers),//--y
                "Series1");                             // Set the display title of the series

        // same as above
   //     XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");

        // Create a formatter to use for drawing a series using LineAndPointRenderer:
        LineAndPointFormatter series1Format = new LineAndPointFormatter(
                Color.rgb(0, 200, 0),                   // line color
                Color.rgb(0, 100, 0),                   // point color
                null);                                  // fill color (none)

        // add a new series' to the xyplot:
        **mySimpleXYPlot.addSeries(series1, series1Format);**

        // same as above:
        //mySimpleXYPlot.addSeries(series2,
          //      new LineAndPointFormatter(Color.rgb(0, 0, 200), Color.rgb(0, 0, 100), null));

        // reduce the number of range labels
        **mySimpleXYPlot.setTicksPerRangeLabel(3);**

        // by default, AndroidPlot displays developer guides to aid in laying out your plot.
        // To get rid of them call disableAllMarkup():
        **mySimpleXYPlot.disableAllMarkup();**

    }
}

*plot_xml.xml:*

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:paddingBottom="@+dimen/activity_vertical_margin"
    android:paddingLeft="@+dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".XYPlot" >

 <com.arise.plotme.XYPlot
            android:id="@+id/mySimpleXYPlot"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10px"
            android:layout_marginLeft="10px"
            android:layout_marginRight="10px"
            title="XY Plot me"/>


</RelativeLayout>

*Plot_Me 清单:*

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.arise.plotme"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.arise.plotme.MainActivity"
            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="com.arise.plotme.XYPlot"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



    </application>



        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />  
    <uses-permission android:name="android.permission.INTERNET" />

</manifest>

实际上我有两个 xml 布局,因为我有两个活动。这是我的第二个活动,我的第一个活动没有错误。

非常感谢任何帮助。

4

1 回答 1

0

请将您的清单文件替换为此。

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.arise.plotme.MainActivity"
        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="com.arise.plotme.XYPlot"
        android:label="@string/app_name" >
     </activity>



</application>



    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />  
<uses-permission android:name="android.permission.INTERNET" />

于 2013-06-17T09:32:40.623 回答