android-developers
[Arriba] [Todas las Listas]

[android-developers] Problema:FingerPaint utilizando surfaceview

To: Android Developers <android-developers@xxxxxxxxxxxxxxxx>
Subject: [android-developers] Problema:FingerPaint utilizando surfaceview
From: Hassy <hasith.bis@xxxxxxxxx>
Date: Mon, 31 Oct 2011 18:56:22 -0700 (PDT)
Delivery-date: Mon, 31 Oct 2011 21:56:40 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:mime-version:date:user-agent:x-http-useragent :message-id:subject:from:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=9NZUO2XfBxMJD6q6HsgjF/Vi/8/QuMxuT7rJZ9ufU+8=; b=4KaH+AOsjY0oUZWk/WNQkHMUAfIAs8ZBL/BnLufzRIxm9plEmtF3vj8dCk3tC0oyNZ GBSuCh3NLPuwOxhahsohMA9yRJPyHbJX0kJ3i8tN+Ta8B5CcsJkTBzcFNtIXkHnOAe6K /HzNSUDFRQ7rRri9OiiaHeXAGg2NatH89iw8s=
Envelope-to: traductor@xxxxxxxxxxx
List-archive: <http://groups.google.com/group/android-developers?hl=en_US>
List-help: <http://groups.google.com/support/?hl=en_US>, <mailto:android-developers+help@googlegroups.com>
List-id: <android-developers.googlegroups.com>
List-post: <http://groups.google.com/group/android-developers/post?hl=en_US>, <mailto:android-developers@googlegroups.com>
List-subscribe: <http://groups.google.com/group/android-developers/subscribe?hl=en_US>, <mailto:android-developers+subscribe@googlegroups.com>
List-unsubscribe: <http://groups.google.com/group/android-developers/subscribe?hl=en_US>, <mailto:android-developers+unsubscribe@googlegroups.com>
Mailing-list: list android-developers@xxxxxxxxxxxxxxxx; contact android-developers+owners@xxxxxxxxxxxxxxxx
Reply-to: android-developers@xxxxxxxxxxxxxxxx
Sender: android-developers@xxxxxxxxxxxxxxxx
User-agent: G2/1.0
Hola,

estoy intentando crear una aplicación de pintura del dedo que utiliza *surfaceview.
He probado y capaz de pintar en la pantalla que utiliza vista pero cuándo utilizo
*surfaceview
,no puedo dibujar en la pantalla.

Puede cualquiera me dice cómo para solucionar este problema.

CÓDIGO

Actividad Principal

clase pública *MainAct extiende Actividad
	#unknown{^*DrawView *drawView;
    @*Override
    público *void *onCreate(*Bundle *savedInstanceState)
        #unknown{^*super.*onCreate(*savedInstanceState);
        // Pone vista de pantalla llena
 
*getWindow().*setFlags(*WindowManager.*LayoutParams.BANDERA_*FULLSCREEN,
                *WindowManager.*LayoutParams.BANDERA_*FULLSCREEN);
        *requestWindowFeature(Ventana.CARACTERÍSTICA_NINGÚN_TÍTULO);

        *drawView = nuevo *DrawView(este);
        *setContentView(*drawView);
        *drawView.*requestFocus();
    }
}



*DrawView.Clase


clase pública *DrawView extiende *SurfaceView implementa
*SurfaceHolder.*Callback
	 #Adj *static TAG de Cadena final = "*DrawView";

	    Punto<de Lista> señala = nuevo *ArrayList<Punto>();
	    la Pintura pinta = Pintura nueva();
	    Hilo *mainLoop = *null;

	    público *DrawView(contexto de Contexto)
	        #unknown{^*super(contexto);

	        *getHolder().*addCallback(Este);
	        *setFocusable(cierto);
	        *setFocusableInTouchMode(cierto);
	        pintura.*setAntiAlias(Cierto);
	        pintura.*setColor(*Color.BLANCO);
	        pintura.*setAntiAlias(Cierto);
	    }
	    público *void *doDraw()
	    	#nom_de_nom de Tela = *getHolder().*lockCanvas();
	    	Tela.*drawColor(*Color.NEGRO);
	    	tela.*drawCircle(50, 50, 50, pintura);
			puesto que (punto de Punto : puntos)
		            #nom.*drawCircle(Punto.*x, punto.*y, 25, pintura);
		            // *Log.*d(TAG, "Pintura: "+punto);

		     }
			 *getHolder().*unlockCanvasAndPost(Tela);
	    }

		@*Override
		público *void *surfaceChanged(*SurfaceHolder titular, *int formato, *int
ancho,
				*int alzada)
			// #unknown{^*TODO Coche-colilla de método generado

		}

		@*Override
		público *void *surfaceCreated(*SurfaceHolder titular)
			// #unknown{^*TODO Coche-colilla de método generado
			*Log.*d(*getClass().*getName(), "*surfaceCreated");
			*doDraw();
		}

		@*Override
		público *void *surfaceDestroyed(*SurfaceHolder titular)
			// #unknown{^*TODO Coche-colilla de método generado

		}
		@*Override
		público *boolean *onTouchEvent(*MotionEvent acontecimiento)
	        // #cnj(acontecimiento.*getAction() != *MotionEvent.ACCIÓN_ABAJO)
	        //regreso *super.*onTouchEvent(Acontecimiento);
			el Punto señala = Punto nuevo();
	        punto.*x = Acontecimiento.*getX();
	        Punto.*y = Acontecimiento.*getY();
	        Puntos.Añade(punto);
	        *Log.*d(TAG, "punto: " + punto);
	        regreso *super.*onTouchEvent(Acontecimiento);
	    }
	}

	Punto de clase
	    #unknown{^*float *x, *y;

	    @*Override
	    Cadena pública *toString()
	        #nom *x + ", " + *y;
	    }
	}



*Thank tú
*Hassy

-- 
recibiste este mensaje porque eres *subscribed al *Google
Grupos "*Android *Developers" grupo.
A correo a este grupo, envía *email a *android-developers@xxxxxxxxxxxxxxxx
A *unsubscribe de este grupo, envía *email a *android-*developers+unsubscribe@xxxxxxxxxxxxxxxx

Puesto que más opciones, visita este grupo en
*http://grupos.*google.*com/Grupo/*android-*developers?*hl=*en

Hello,

I'm trying to create a finger paint application using surfaceview.
I have tried and able to paint on the screen using view but when I use
surfaceview
,I can't draw on the screen.

can anybody tell me how to solve this problem.

CODE

Main Activity

public class MainAct extends Activity {
	DrawView drawView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Set full screen view
 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        drawView = new DrawView(this);
        setContentView(drawView);
        drawView.requestFocus();
    }
}



DrawView.class


public class DrawView extends SurfaceView implements
SurfaceHolder.Callback{
	 private static final String TAG = "DrawView";

	    List<Point> points = new ArrayList<Point>();
	    Paint paint = new Paint();
	    Thread mainLoop = null;

	    public DrawView(Context context) {
	        super(context);

	        getHolder().addCallback(this);
	        setFocusable(true);
	        setFocusableInTouchMode(true);
	        paint.setAntiAlias(true);
	        paint.setColor(Color.WHITE);
	        paint.setAntiAlias(true);
	    }
	    public void doDraw(){
	    	Canvas canvas = getHolder().lockCanvas();
	    	canvas.drawColor(Color.BLACK);
	    	canvas.drawCircle(50, 50, 50, paint);
			for (Point point : points) {
		            canvas.drawCircle(point.x, point.y, 25, paint);
		            // Log.d(TAG, "Painting: "+point);

		     }
			 getHolder().unlockCanvasAndPost(canvas);
	    }

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

		}

		@Override
		public void surfaceCreated(SurfaceHolder holder) {
			// TODO Auto-generated method stub
			Log.d(getClass().getName(), "surfaceCreated");
			doDraw();
		}

		@Override
		public void surfaceDestroyed(SurfaceHolder holder) {
			// TODO Auto-generated method stub

		}
		@Override
		public boolean onTouchEvent(MotionEvent event) {
	        // if(event.getAction() != MotionEvent.ACTION_DOWN)
	        //return super.onTouchEvent(event);
			Point point = new Point();
	        point.x = event.getX();
	        point.y = event.getY();
	        points.add(point);
	        Log.d(TAG, "point: " + point);
	        return super.onTouchEvent(event);
	    }
	}

	class Point {
	    float x, y;

	    @Override
	    public String toString() {
	        return x + ", " + y;
	    }
	}



Thank you
Hassy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
android-developers+unsubscribe@xxxxxxxxxxxxxxxx
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<Anterior por Tema] Tema Actual [Siguiente por Tema>