【问题标题】:Android AChartEngine Chart Bitmap NullPointerExceptionAndroid AChartEngine 图表位图 NullPointerException
【发布时间】:2012-08-08 18:19:31
【问题描述】:

我知道之前有人问过这个问题,但从那时起我就没有看到任何答案。因此,如果有人能在这方面指导我,我将不胜感激。

Android need help with diagram

我在下面的部分有一个错误:

        double x = 0;
    double y = 0;


    for (int i=0;i<10;i++)
    {
        x=x+10;
        y=y+5;
        mCurrentSeries.add(x, y);
    }

    Log.i("Series Count",""+mCurrentSeries.getItemCount());


    for (int xy=0;xy<10;xy++)
    {
    Log.i("Series -- Values","["+mCurrentSeries.getX(xy)+","+mCurrentSeries.getY(xy)+"]");
    }

    if (mChartView != null) {
        mChartView.repaint();
    }

    Bitmap bitmap = mChartView.toBitmap();

    try {
        File file = new File(Environment.getExternalStorageDirectory(),
                "test" + index++ + ".png");
        OutputStream output = new FileOutputStream(file);
        bitmap.compress(CompressFormat.PNG, 100, output);   

        output.flush();
        output.close(); 
    } catch (Exception e) {
        Toast.makeText(LineChartTestActivity.this, "Graph Exception", Toast.LENGTH_LONG).show();//Added Toast to see exception on device
        Log.e("ERROR", "BITMAP EXCEPTION");
        e.printStackTrace();

    }

具体来说,下面一行给了我一个 java.lang.NullPointerException

bitmap.compress(CompressFormat.PNG, 100, output);

就像 Handy 在他的问题中提到的那样,我也可以使用 editText 使其工作,但由于某些奇怪的原因,当我从代码中给出明确的值时它不会工作!

请指教。

【问题讨论】:

    标签: android bitmap nullpointerexception achartengine linegraph


    【解决方案1】:

    曾经有一个未解决的问题。请看cmetshere,也许它会帮助你保存位图。

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多