0

我有一个时间表,Y 轴上有 2 条线,X 轴上有日期。我的问题是,当我放大图表时,它超出了手机屏幕,当我尝试滚动它时,活动崩溃了。

任何建议都会有所帮助谢谢

这是我的代码

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

                        TimeSeries fPriceseries = new TimeSeries("Fuel prices");
                        for (int i = 0; i < fDates.length; i++)
                        {
                                try 
                                {
                                    fPriceseries.add(sdf.parse(fDates[i].trim()), fPrice[i]);
                                } 
                                catch (ParseException e)
                                {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                        }

                        TimeSeries fMileageSeries = new TimeSeries("Mileage");
                        for(int i=0;i<fDates.length;i++)
                        {
                            try 
                            {
                                fMileageSeries.add(sdf.parse(fDates[i].trim()), fMileage[i]);
                            } 
                            catch (ParseException e) 
                            {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }


                        }

                            dataset = new XYMultipleSeriesDataset();
                            dataset.addSeries(fPriceseries);
                            dataset.addSeries(fMileageSeries);




                            rRenderer = new XYMultipleSeriesRenderer();
                            rRenderer.setMargins(new int[] { 20, 30, 15, 0 });
                            rRenderer.setZoomButtonsVisible(true);
                            rRenderer.setZoomEnabled(true);
                            rRenderer.setMarginsColor(Color.argb(0x00, 0x01, 0x01, 0x01));
                            rRenderer.setLabelsColor(Color.BLACK);
                            rRenderer.setApplyBackgroundColor(true);
                            rRenderer.setLabelsTextSize(15f);
                            rRenderer.setLegendTextSize(15f);
                            rRenderer.setGridColor(Color.BLACK);
                            rRenderer.setAxisTitleTextSize(18f);
                            rRenderer.setAxesColor(Color.BLACK);
                            rRenderer.setXTitle("Dates");
                            rRenderer.setXLabelsColor(Color.BLACK);
                            rRenderer.setYTitle("Values");
                            rRenderer.setYLabelsColor(0, Color.BLACK);
                            rRenderer.setBackgroundColor(Color.TRANSPARENT);
                            rRenderer.setXRoundedLabels(false);
                            rRenderer.setXLabelsAlign(Align.CENTER);

                            // Customization time for line 1!

                            priceRenderer = new XYSeriesRenderer();
                            priceRenderer.setDisplayChartValues(true);
                            priceRenderer.isDisplayChartValues();
                            priceRenderer.setDisplayChartValuesDistance(10);
                            priceRenderer.setColor(Color.parseColor("#FFDC143C"));
                            priceRenderer.setPointStyle(PointStyle.CIRCLE);
                            priceRenderer.setFillPoints(true);
                            rRenderer.addSeriesRenderer(priceRenderer);


                            // Customization time for line 2!
                            mileageRenderer = new XYSeriesRenderer();
                            mileageRenderer.setDisplayChartValues(true);
                            mileageRenderer.setDisplayChartValuesDistance(10);
                            mileageRenderer.setPointStyle(PointStyle.CIRCLE);
                            mileageRenderer.setColor(Color.parseColor("#FF6B8E23"));
                            mileageRenderer.setFillPoints(true);
                            rRenderer.addSeriesRenderer(mileageRenderer);

                            Intent lineIntent = ChartFactory.getTimeChartIntent(context, dataset, rRenderer,"dd/MM/yy","Reports");
                           return lineIntent;

错误日志:-

08-15 12:59:14.230: E/EGL_emulation(1694): rcCreateContext returned 0
08-15 12:59:14.230: E/EGL_emulation(1694): tid 1694: eglCreateContext(881): error 0x3003 (EGL_BAD_ALLOC)
08-15 12:59:14.320: E/libEGL(1694): eglMakeCurrent:493 error 3009 (EGL_BAD_MATCH)
08-15 12:59:14.330: E/ViewRootImpl(1694): OutOfResourcesException initializing HW surface
08-15 12:59:14.330: E/ViewRootImpl(1694): android.view.Surface$OutOfResourcesException: eglMakeCurrent failed EGL_BAD_MATCH
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.HardwareRenderer$GlRenderer.createEglSurface(HardwareRenderer.java:920)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:748)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1505)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.Choreographer.doFrame(Choreographer.java:525)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.os.Handler.handleCallback(Handler.java:615)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.os.Handler.dispatchMessage(Handler.java:92)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.os.Looper.loop(Looper.java:137)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at android.app.ActivityThread.main(ActivityThread.java:4745)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at java.lang.reflect.Method.invokeNative(Native Method)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at java.lang.reflect.Method.invoke(Method.java:511)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-15 12:59:14.330: E/ViewRootImpl(1694):   at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

1

您是在模拟器还是真实设备上测试您的应用程序?根据开发人员指南,当您的表面无法重新调整大小或创建时,将引发异常。您可以尝试更改模拟器设置(允许更多内存),或者可以在真实设备上尝试。

于 2013-08-15T07:55:55.157 回答