Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android


 
Herramientas
  #1  
Viejo 21/12/13, 12:50:07
Avatar de vfr92
vfr92 vfr92 no está en línea
Usuario novato en la web
Mensajes: 1
 
Fecha de registro: dic 2013
Mensajes: 1
Tu operador: Movistar
Mencionado: 0 comentarios
Tagged: 0 hilos
Dibujar sobre una imagen

Hola, soy nuevo en esto de Android y me gustaría que me ayudarais.
Quiero montarme una aplicación de un calendario. Una serie de imagenes, una de cada mes y sobre ella poder dibujar linias, circulos etc etc
Hasta ahí bien. Lo que hago es crear un MySurfaceView que extiende a SurfaceView. Por otro lado, le cambio el background y le pongo un drawable y al pintar los círculos no hace nada. Si por el contrario, no cambio el background si que dibuja los círculos allá donde pulses.
¿Alguna idea de lo que puede estar pasando?
Aquí pongo el código
Gracias de antemano

public class MySurfaceView extends SurfaceView implements SurfaceHolder.Callback {

private MySurfaceThread thread;

volatile private List<Circle> circlesList;

public boolean touched;

@SuppressLint("NewApi")
public MySurfaceView(Context context) {
super(context);
getHolder().addCallback(this);
circlesList = new LinkedList<Circle>();
circlesList = Collections.synchronizedList(circlesList);
// this.setBackground(getResources().getDrawable(R.dr awable.enero2014));
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// TODO Auto-generated method stub

}

@Override
public void surfaceCreated(SurfaceHolder holder) {
this.thread = new MySurfaceThread(getHolder(), this);
this.thread.setRunning(true);
this.thread.start();
}

@Override
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;

thread.setRunning(false);

while(retry) {
try {
this.thread.join();
retry = false;
} catch (InterruptedException e) {

}
}
}

@SuppressLint("NewApi")
@Override
public void onDraw(Canvas canvas) {

for(int i = 0; i < circlesList.size(); i++){
canvas.drawCircle(circlesList.get(i).getPosX(), circlesList.get(i).getPosY(), 10, circlesList.get(i));
}

}

@Override
public boolean onTouchEvent(MotionEvent event) {
int touchedX = (int) event.getX();
int touchedY = (int) event.getY();
Circle pcirculo = new Circle(touchedX, touchedY, Color.RED);
pcirculo.setStyle(Paint.Style.FILL);
circlesList.add(pcirculo);

return true;
}
}
Responder Con Cita


Respuesta

Estás aquí
Regresar   HTCMania > Todo sobre Android > Programación y Desarrollo para Android

Herramientas

Reglas de Mensajes
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Las caritas están On
Código [IMG] está On
Código HTML está Off

Saltar a Foro



Hora actual: 04:56:40 (GMT +2)

Cookies settings
Powered by vBulletin™
Copyright © vBulletin Solutions, Inc. All rights reserved.
 
HTCMania: líderes desde el 2007