我爲我的應用程序寫了一個小繪圖儀。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