我为我的应用程序写了一个小绘图仪。ArrayList中的更快项目<T>
该函数需要很多时间,还有另一种方法,在Canvas中绘制得更快吗?
String auggabe = "x+2";
float xMitte = step * (count_w/2); //stepp is 100px, count_w is 20
float yMitte = step * (count_h/2); //count_h is 10
ArrayList<Float[]> yWerte = new ArrayList<>();
for(float i = (count_w/2 * -1);i <= count_w/2; i = getF(i + 0.15f))
{
Log.d("FC", Float.toString(i));
String a = new math_compile(auggabe.replace("x", String.valueOf(i)), 0).getAufgabe();//is a class they give me the arithmetic problem value
float y = Float.parseFloat(a.replace(" ","")) ;
yWerte.add(new Float[]{i, y*-1});
}
这个代码是我的问题,它的NEET长为133项 绘制belowe有
for(int inde = 0; inde <= yWerte.size()-2; inde++)
{
Float[] xy = yWerte.get(inde);
Float[] xyII = yWerte.get(inde + 1);
canvas.drawLine((xy[0] * step) + xMitte, (xy[1] * step) + yMitte, (xyII[0] * step) + xMitte, (xyII[1] * step) + yMitte, fc);
}
圆浮
private float getF(float y)
{
DecimalFormat df = new DecimalFormat("#.##");
String twoDigitNum = df.format(y).replace(",",".");
Log.d("getF", twoDigitNum);
return Float.parseFloat(twoDigitNum);
}
简介您的应用程序,并点具体的问题在你的代码 –
问题SI不是ArrayList中,它的字符串解析和格式化。 – Natix
此外,(联合国)拳击可以降低性能。使用'float []'而不是'Float' []。 – Natix