我知道这个问题曾经问过一次,但我从那时起就没有回答。因此,如果你有人可以在这方面指导我,我将不胜感激。
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使其工作,但由于某些奇怪的原因,当我从代码中提供显式值时,它将无法工作!
请告知。