这是我的代码的一部分,如果我在其他代码中使用其他活动中的代码,例如:
case R.id.buttonMinus:
它工作正常,它只保存该特定按钮的背景。如果我在graphview中使用它,它总是以“Error1”结束。 (Graphview是一个将图形绘制到画布中的视图)
另外,我想在应用程序的某个不同位置显示图片,我一直试图通过
myWebView.loadUrl(Environment.getExternalStorageDirectory()+ File.separator + "DivePlanner" + File.separator + "Dive.png");
但没有运气
如果有人可以提供帮助,我一整天都被困在这一天,谢谢你们!
buttonClick.performClick();
}
public void onClick(View v) {
String[] verlabels = new String[] {"0m", Float.toString(-max/2) + "m", Float.toString(-max) + "m"};
String[] horlabels = new String[] {"0 min",Float.toString((int)x[pocetBodu]/2)+" min",Float.toString((int)x[pocetBodu])+" min"};
GraphView graphView = new GraphView(this, y, "Dive Manager",horlabels, verlabels, GraphView.LINE,x,Pspotreba,pocetBodu,pocetUseku);
setContentView(graphView);
if(Save)
{
graphView.buildDrawingCache();
Bitmap bm=graphView.getDrawingCache();
OutputStream fOut = null;
Uri outputFileUri;
try {
File root = new File(Environment.getExternalStorageDirectory()+ File.separator + "DivePlanner" + File.separator);
root.mkdirs();
File sdImageMainDirectory = new File(root, "Dive.png");
outputFileUri = Uri.fromFile(sdImageMainDirectory);
fOut = new FileOutputStream(sdImageMainDirectory);
}
catch (Exception e) {
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
}
try {
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
Toast.makeText(this, "Ponor uložen", Toast.LENGTH_SHORT).show();
}
catch (Exception e) {
Toast.makeText(this, "Error1", Toast.LENGTH_SHORT).show();
}
}