0
こんにちは私は1つの折れ線グラフを描画しようとしており、そのためにこのコードを使用しています。他のクラスからグラフを更新するには?
DrawGraph dg = new DrawGraph(this);
pane.addView(dg);
dg.setData(10, 10, 100, 100); //cords. for Firs Line
pane.invalidate();
dg.setData(100, 100, 100, 300); //cords. for second Line
pane.invalidate();
これは私のDrawGraphクラスです。問題がある
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;
public class DrawGraph extends View{
Paint p;
int x1;
int y1;
int x2;
int y2;
Canvas fc;
int i = 0;
public DrawGraph(Context context) {
super(context);
p = new Paint();
fc = new Canvas();
}
public void setData(int x1, int y1, int x2, int y2)
{
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public void onDraw(Canvas c){
c.drawLine(x1, y1, x2, y2, p);
}
}
しかし、私は一度、グラフ内のすべての行を意味し、私はグラフ(第2ライン)に一つだけの行を見ることができると私は両方の線 を必要としています。 解決方法を教えてください。ありがとう。