错误:eglSurfaceAttrib未实现

时间:2014-01-22 20:49:56

标签: android achartengine linegraph

我正在尝试使用aChartEngine显示折线图,但是,页面显示为空白,我收到错误“eglSurfaceAttrib not implemented”

进度代码(显示)页面:

    <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=".LineGraph" >


     </RelativeLayout>

LineGraph.java的代码:

    package com.lifematters;

    import org.achartengine.ChartFactory;
    import org.achartengine.model.TimeSeries;
    import org.achartengine.model.XYMultipleSeriesDataset;
    import org.achartengine.renderer.XYMultipleSeriesRenderer;
    import org.achartengine.renderer.XYSeriesRenderer;

    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;

    public class LineGraph extends Activity {

//define layout
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progress);
}

public Intent getIntent(Context context)
{

    int[] x = {1, 2, 3, 4, 5, 6, 7}; //x values
    int[] y = {3, 2, 3, 4, 2, 1, 3}; //y values

    //need to create series as graph does not support arrays
    TimeSeries series = new TimeSeries("Line1");
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

    //allows more than 1 line to be added to linegraph  
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    dataset.addSeries(series);

    //customize lines
    XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
    XYSeriesRenderer renderer = new XYSeriesRenderer();
    mRenderer.addSeriesRenderer(renderer);

    Intent intent = ChartFactory.getLineChartIntent(context, dataset, mRenderer,
             "Line Graph Title");
            return intent;


       }

          }

.MainActivity的代码:

    package com.lifematters;

    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.View;
    import android.widget.ImageButton;

    public class MainActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

      //define Navigation Image Buttons
      final ImageButton progressBtn = (ImageButton) findViewById(R.id.ImagebtnProgress);


      //Set up listener for Progress
      progressBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            //listener call this function
            openProgress();
        }
    });

        }

        //Open progress page
        public void openProgress() {
        //create new textview
        Intent i = new Intent(getApplicationContext(), LineGraph.class);
        startActivity(i);
        }

        public void lineGraphHandler (View view)
        {
        LineGraph line = new LineGraph();
        Intent lineIntent = line.getIntent(this);
        startActivity(lineIntent);
        }

        }

这是日志猫:

01-22 23:44:24.583: E/Trace(3973): error opening trace file: No such file or directory (2)
01-22 23:44:24.703: D/dalvikvm(3973): GC_CONCURRENT freed 149K, 3% free 10996K/11271K, paused 13ms+5ms, total 70ms
01-22 23:44:24.707: D/dalvikvm(3973): WAIT_FOR_CONCURRENT_GC blocked 50ms
01-22 23:44:24.775: D/dalvikvm(3973): GC_FOR_ALLOC freed 93K, 4% free 11162K/11527K, paused 14ms, total 15ms
01-22 23:44:24.851: D/libEGL(3973): loaded /system/lib/egl/libEGL_emulation.so
01-22 23:44:24.855: D/(3973): HostConnection::get() New Host Connection established 0xb885bbf8, tid 3973
01-22 23:44:24.867: D/libEGL(3973): loaded /system/lib/egl/libGLESv1_CM_emulation.so
01-22 23:44:24.867: D/libEGL(3973): loaded /system/lib/egl/libGLESv2_emulation.so
01-22 23:44:24.955: W/EGL_emulation(3973): eglSurfaceAttrib not implemented
01-22 23:44:24.979: D/OpenGLRenderer(3973): Enabling debug mode 0
01-22 23:44:25.027: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb8866190): name, size, mSize = 1, 1048576, 1048576
01-22 23:44:25.107: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb8864ad0): name, size, mSize = 2, 9216, 1057792
01-22 23:44:25.187: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb8878a60): name, size, mSize = 4, 36864, 1094656
01-22 23:44:25.207: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb8864638): name, size, mSize = 6, 13312, 1107968
01-22 23:44:25.215: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb886f080): name, size, mSize = 7, 43264, 1151232
01-22 23:44:25.219: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb88664a8): name, size, mSize = 8, 43264, 1194496
01-22 23:44:25.227: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb886f6c8): name, size, mSize = 9, 57600, 1252096
01-22 23:44:25.239: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb886f738): name, size, mSize = 10, 77284, 1329380
01-22 23:44:25.243: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb887f598): name, size, mSize = 11, 88804, 1418184
01-22 23:44:25.251: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb886da70): name, size, mSize = 12, 73984, 1492168
01-22 23:44:25.255: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb886d918): name, size, mSize = 13, 43264, 1535432
01-22 23:44:25.259: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb8864f28): name, size, mSize = 14, 43264, 1578696
01-22 23:44:25.263: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb887e3e8): name, size, mSize = 15, 4096, 1582792
01-22 23:44:38.119: D/OpenGLRenderer(3973): TextureCache::get: create texture(0xb88942a0): name, size, mSize = 19, 13312, 1596104
01-22 23:44:38.767: W/EGL_emulation(3973): eglSurfaceAttrib not implemented

非常感谢任何帮助。谢谢

3 个答案:

答案 0 :(得分:2)

从您的错误日志中

android.content.ActivityNotFoundException:无法找到显式活动类{com.lifematters / com.lifematters.LineGraph};你有没有在AndroidManifest.xml中声明这个活动?

答案 1 :(得分:0)

试试这个

 public void openProgress() {
        //create new textview
         LineGraph line = new LineGraph();
        Intent lineIntent = line.getIntent(this);
        startActivity(lineIntent);
        }

public void openProgress() {

   lineGraphHandler();
    }

    public void lineGraphHandler ()
    {
    LineGraph line = new LineGraph();
    Intent lineIntent = line.getIntent(this);
    startActivity(lineIntent);
    }

答案 2 :(得分:0)

为您的主要活动添加此代码

  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button b2;
    b2=(Button)findViewById(R.id.button2);
    b2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent i = new Intent(getApplicationContext(), MyLine.class);
            startActivity(i);
        }
    });

我已将我的课程设为MyLine,因此请将其添加到MyLine课程

  package com.isuru.mychater;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.model.TimeSeries;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RelativeLayout;

public class MyLine extends Activity{



@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
     setContentView(R.layout.line);
     //getIntent(this);
     MyLine  line = new MyLine();
     GraphicalView gview = line.getView(this);
     RelativeLayout layout =(RelativeLayout)findViewById(R.id.chart);
     layout.addView(gview);
}

public GraphicalView getView(Context context)
{

    int[] x = {1, 2, 3, 4, 5, 6, 7}; //x values
    int[] y = {3, 2, 3, 4, 2, 1, 3}; //y values

    //need to create series as graph does not support arrays
    TimeSeries series = new TimeSeries("Line1");
        for( int i = 0; i < x.length; i++)
        {
            series.add(x[i], y[i]);
        }

    //allows more than 1 line to be added to linegraph  
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();

    dataset.addSeries(series);

    //customize lines
    XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
    XYSeriesRenderer renderer = new XYSeriesRenderer();
    mRenderer.addSeriesRenderer(renderer);

   return  ChartFactory.getLineChartView(context, dataset, mRenderer);



       }

}

我的line.xml文件的电话

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<RelativeLayout
    android:id="@+id/chart"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >
</RelativeLayout>

也不能将清单文件更新为

<activity
        android:name="com.isuru.mychater.MyLine"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MYLINE" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity android:name="org.achartengine.GraphicalActivity"/>

enter link description here

enter image description here

查看基本

的链接

enter link description here

希望这条线对你有帮助。