s0uLx09
Lurker
Hi,
I am new to android programming and I am trying to create an application that randomly appear green circle for user to click on. My current code doesnt even make an circle appear. Does anyone have an answer to it?
protectedvoid onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
String timeData = getIntent().getExtras().getString("timeDuration");
if(timeData =="30sec"){
timeLeft =30;
}
textViewTime =(TextView)findViewById(R.id.textViewTime);
textViewScore =(TextView)findViewById(R.id.textViewScore);
textViewTime.setText(timeData);
finalCounterClass timer =newCounterClass(30000,1000);
timer.start();
onDraw();
}
privatevoid onDraw(){
Random random =newRandom();
Display display = getWindowManager().getDefaultDisplay();
Point screenSize=newPoint();
display.getSize(screenSize);
int width = screenSize.x;
int height = screenSize.y;
float x =random.nextFloat()* width;
float y =random.nextFloat()* height;
Paint paint =newPaint();
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
int RADIUS =50;
Canvas canvas =newCanvas();
canvas.drawCircle(x, y, RADIUS, paint);
}
I am new to android programming and I am trying to create an application that randomly appear green circle for user to click on. My current code doesnt even make an circle appear. Does anyone have an answer to it?
protectedvoid onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
String timeData = getIntent().getExtras().getString("timeDuration");
if(timeData =="30sec"){
timeLeft =30;
}
textViewTime =(TextView)findViewById(R.id.textViewTime);
textViewScore =(TextView)findViewById(R.id.textViewScore);
textViewTime.setText(timeData);
finalCounterClass timer =newCounterClass(30000,1000);
timer.start();
onDraw();
}
privatevoid onDraw(){
Random random =newRandom();
Display display = getWindowManager().getDefaultDisplay();
Point screenSize=newPoint();
display.getSize(screenSize);
int width = screenSize.x;
int height = screenSize.y;
float x =random.nextFloat()* width;
float y =random.nextFloat()* height;
Paint paint =newPaint();
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
int RADIUS =50;
Canvas canvas =newCanvas();
canvas.drawCircle(x, y, RADIUS, paint);
}