伙计我想用不同的颜色绘制弧线,但它根本没有显示任何活动,我是android新手,
谢谢,
ggplot(plotdf, aes(y = fit, x = Anger, color = btype, group = btype)) +
geom_point() + geom_smooth(aes(color = btype), method = "lm") +
facet_wrap(~situ) + theme_bw() +
labs(y = "Predicted Probability")
答案 0 :(得分:1)
1)在onDraw不良练习中创建一支铅笔。 (长期运作)
2)你需要super.onDraw
@Override
public void onDraw(Canvas canvas)
{
super.onDraw(canvas);
3)删除Thread.sleep(10000);
4)你需要一个asynctask来调用onProgressUpdate中的invalidate()。您的代码将如下所示:
class StupidTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
int i;
for(i=0;i<500;i++)
{
Thread.sleep(10000);
paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
publishProgress();
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Void... params) {
super.onProgressUpdate(values);
postInvalidate();
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
invalidate();
}
}
答案 1 :(得分:0)
我的猜测是onDraw方法实际上需要完成。因此,尝试让你的线程在活动中休眠,并且每隔10秒使视图无效,这将再次调用onDraw
答案 2 :(得分:0)
1)如果你只想用不同颜色绘制弧线,这就是我的代码。
method
2)您可以使用canvas.drawPath()绘制任何指定的路径,例如
paint = new Paint();
rectF = new RectF(50, 20, 500, 580);
paint.setAntiAlias(true);
paint.setColor(Color.RED);
canvas.drawColor(Color.GREEN);
paint.setStrokeWidth(12);
int startAngle = 90,sweepAngle = 45;
for(int i = 0; i < 10; i++)
{
paint.setARGB(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
canvas.drawArc(rectF, startAngle, sweepAngle, true, paint); //绘制圆弧
startAngle += sweepAngle;
}
3)使用此视图:
rnd = new Random();
obj = new Path();
obj.moveTo(50, 100);
for(int i = 0; i < 10; ++i)
{
obj.lineTo(rnd.nextInt(100), rnd.nextInt(100));
}
canvas.drawPath(obj, paint);