canvas 绘制文本 - 无法获取字符串

canvas draw text- cant get strings

String str = new String();
str = "111";
x = width / 2;
y = Math.round(height / 1.3);

while (pressed != true){
    if (!holder.getSurface().isValid()) 
        continue;
    Canvas c = holder.lockCanvas();
    c.drawBitmap(galaxy, 0, 0, null);
    c.drawBitmap(player, x - (player.getWidth() / 2), y - (player.getHeight() / 2), null);
    c.drawText("111", c.getWidth() / 12, c.getHeight() / 15, timerpaint);

    holder.unlockCanvasAndPost(c);
}

我试着把str insted "111" 放在"drawText" 函数里,但它没有写任何东西,我不知道为什么。

谢谢!

添加

Paint paint = new Paint(); 
paint.setColor(Color.BLACK); // any color you like  
paint.setStyle(Style.FILL); 
canvas.drawPaint(paint); 

开始绘画之前

替换为:

String str = new String(); 
str = "111";

有了这个:

String str = " 111";

希望我的回答对您有所帮助。