저는 Java와 android에서 새롭습니다. 내 첫 번째 응용 프로그램은 캔버스와 페인트를 사용합니다. 어떤 이유로 drawText 메서드를 사용할 때마다 강제로 닫습니다. 제발 도와주세요. 기본적으로 특정 x, y 좌표로 텍스트를 표시하려고합니다. 게임 내내 업데이트가 필요합니다. 내 코드 :drawText Canvas 메서드가 작동하지 않습니다.
public class MyGame extends Main {
TextView timeDisplay;
public String clock;
int x_pos = 10;
int y_pos = 100;
int radius = 20;
float x = 10;
float y = 20;
android.graphics.Paint p;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// setup Drawing view
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.drawText("test", 30, 0,x,y, p); <-- if I comment this out, no force close...
귀하의 도움에 감사드립니다.